cancel
Showing results for 
Search instead for 
Did you mean: 

Changing date format in locale

Former Member
0 Kudos

Hi Experts,

Date, currency format and so on depends on locale. If locale changes formats change as well.

But is possible to change these formats in locale itself (change, for example, short date format in locale en_US to dd/mm/yyyy instead of mm/dd/yyyy)?

Best Regards

Price Young

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try this code

Date currentDate = new Date ();

DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);

String today = df.format(currentDate);

System.out.println("Today Date "+currentDate);

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

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

try {

System.out.println("Date format "+sdfOutput.format((Date) sdfInput.parse(df.format(currentDate))));

} catch (ParseException e) {

System.out.print(e);

}

Regards

Suresh

Former Member
0 Kudos

Hi everybody,

The question is not how to change the format in particular coding block.

I need to change the format for the whole J2EE Engine without coding.

Regards

Price

Former Member
0 Kudos

Hi there,

You need to use simpledateformat to format the date output that you want. However, note that you need to create a Date object first before you can do the manipulation.

Former Member
0 Kudos

Hi,

Have a look at Simpledateformat

http://java.sun.com/docs/books/tutorial/i18n/format/simpleDateFormat.html

Regards

Ayyapparaj