OPERATING SYSTEM
----------------
Platform independent
FULL JDK VERSION(S)
-------------------
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)
DESCRIPTION
-----------
Compile and run the attached testcase.
Results from Java 5.0 (correct):
=================th=================
????????? 26 ?????? ?.?. 2008, 15 ?????? 20 ???? 00 ??????
26 ?????? 2008, 15 ?????? 20 ????
26 ??.?. 2008, 15:20:00
26/3/2008, 15:20 ?.
===============th_TH================
????????? 26 ?????? ?.?. 2551, 15 ?????? 20 ???? 00 ??????
26 ?????? 2551, 15 ?????? 20 ????
26 ??.?. 2551, 15:20:00
26/3/2551, 15:20 ?.
Results from Java 6 (incorrect):
=================th=================
??????, ?????? 26, 2008 3:25:47 ?????????? GMT
?????? 26, 2008 3:25:47 ?????????? GMT
??.?. 26, 2008 3:25:47 ??????????
3/26/08 3:25 ??????????
===============th_TH================
????????? 26 ?????? ?.?. 2551, 15 ?????? 25 ???? 47 ??????
26 ?????? 2551, 15 ?????? 25 ????
26 ??.?. 2551, 15:25:47
26/3/2551, 15:25 ?.
The DateTimePatterns are defined in the locale file "FormatData_th.java" with the key "sun.util.BuddhistCalendar.DateTimePatterns"
In SimpleDateFormat.java, if the calendar of the locale is not Gregorian, the patterns with the key "sun.util.BuddhistCalendar.DateTimePatterns" are retrieved, otherwise we search for the key "DateTimePatterns".
In this issue, the calendar for the locale 'th' is Gregorian (since only 'th_TH' is constructed with BuddhistCalendar), so we try to search with the key "DateTimePatterns". However, there is no information with the key "DateTimePatterns" in FormatData_th.java, so the patterns default to the English locale.
This problem may have been introduced during the refactoring of the TZ/locale data under CR 5013088. Unfortunately I do not have access to the old Mustang beta builds to check this hypothesis. I've checked back as far as I can, to the 6.0 GA release, and the problem is there.
TESTCASE SOURCE
---------------
import java.util.Locale;
import java.util.*;
class ThaiTest {
public static void main(String[] args) {
java.util.Date current = new java.util.Date();
System.out.println("=================th=================");
Locale locale = new Locale("th");
java.text.DateFormat javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL, java.text.DateFormat.FULL, locale);
System.out.println(javaDateFormatter.format(current));
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG, locale);
System.out.println(javaDateFormatter.format(current));
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM, java.text.DateFormat.MEDIUM, locale);
System.out.println(javaDateFormatter.format(current));
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.SHORT, java.text.DateFormat.SHORT, locale);
System.out.println(javaDateFormatter.format(current));
System.out.println("===============th_TH================");
locale = new Locale("th","TH");
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL, java.text.DateFormat.FULL, locale);
System.out.println(javaDateFormatter.format(current));
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG, locale);
System.out.println(javaDateFormatter.format(current));
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM, java.text.DateFormat.MEDIUM, locale);
System.out.println(javaDateFormatter.format(current));
javaDateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.SHORT, java.text.DateFormat.SHORT, locale);
System.out.println(javaDateFormatter.format(current));
}
}
Release Regression From : 5
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.