cancel
Showing results for 
Search instead for 
Did you mean: 

Changing date format

Former Member
0 Kudos

Hi all

I am using date context variable bound with InputField to get date from user.But it is showing the date in mm/dd/yyyy format when user selects a date.I want to display it in dd/mm//yyyy format when user selects.

How can I do this

Thanks in advance

Fahad Hamsa

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

use this

SimpleDateFormat fmtDatePlain = new SimpleDateFormat("dd/mm/yyyy");

String formattedDate = fmtDatePlain.format(date);

You get the formatted date..

Regards

Saravanan K

Former Member
0 Kudos

But my field is of type date and the code u had given will return String.When I am converting this string to date and assign it to the field,it will be of mm/dd/yy format again.

I cant leave that date context element because I needs the date picker for picking the date

Former Member
0 Kudos

When I converted like this I am getting Illegal Arg Exception

Former Member
0 Kudos

You can change the locale of your application. The date format depends on that locale.

Regards

Sebastian

Former Member
0 Kudos

Hi Fahad,

You can also create a Simple Type in your local dictionary, use "date" for the type and enter your required format in the representation tab.

Assign this to your context attribute.

Then you will still get the DateNavigator and have your format.

Trying this out in the past I've seen strange formatting effects, though: after picking a date some default format seems sometimes to be used.

Regards

Markus

Former Member
0 Kudos

Hi,

See the following thread:

This might be solve your problem.

Kind Regards,

S.Saravanan.

Former Member
0 Kudos

Thanks Markus.It is working

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

do you want to set the dateformat in the portal.

Kind Regards

Mukesh

Former Member
0 Kudos

Hi

try This

SimpleDateFormat simple=new SimpleDateFormat("DD/MM/yyyy

");

String newdat=simple.format(olddate);

Kind Regards

Mukesh