Sunday, February 27, 2011

DateTimeFormat - No support for Buddhist calendar?

Our users require dates to be input and displayed using the Buddhist calendar - where the year is 543 years greater than the Gregorian calendar.

In normal Java, the following works:

Locale locale = new Locale("th", "TH");
DateFormat dateFormat = new SimpleDateFormat("EEEE dd/MM/yyyy", locale);
System.out.println("Date is: " + dateFormat.format(new Date()));
which outputs
Date is: วันจันทร์ 28/02/2554
This is the result we require.

Trying the equivalent in GWT, I set the locale to "th_TH", and ran the following code:

DateTimeFormat dateFormat = DateTimeFormat.getFormat("EEEE dd/mm/yyyy");
System.out.println("Date is: " + dateFormat.format(new Date()));
which outputs
Date is: วันจันทร์ 28/02/2011

ie the year is incorrect (2011, should be 2554).

It appears that the DateTimeFormat class does not support the +543 year offset required for the Buddhist calendar. I've tried looking through the GWT source + generated code, and it appears that this is the case.

Is this a deficiency of the DateTimeFormat class, or am I missing a trick?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment