0

In java you can get the date format based for a specific locale by doing:

Locale locale = new Locale("en", "UK");
DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
System.out.println( ((SimpleDateFormat)format).toPattern());

This prints

dd-MMM-yyyy

Is this pattern hardcoded in a properties file somewhere? Is there any way I can extend the java mechanism and apply my own pattern (locale dependent) so when I run the above code I get:

dd-MM-yyyy
Maroun
  • 94,125
  • 30
  • 188
  • 241
Luis Gonçalves
  • 249
  • 2
  • 10

1 Answers1

0

The idea is to work always with the same format, in my case the DateFormat.SHORT.

I end up using the short format and replacing the default format containing 2 character for the year with 4 characters for the year.

And in case someone want to know, the formats are indeed hardcoded in the package sun.text.resources under the classes FormatData_XX_YY (e.g. FormatData_en_UK).

Luis Gonçalves
  • 249
  • 2
  • 10