JDK-6683975 : [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 6u5
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 2008-04-03
  • Updated: 2010-07-29
  • Resolved: 2009-02-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u12Fixed 7 b46Fixed
Related Reports
Relates :  
Description
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.

Comments
SUGGESTED FIX ------- FormatData_th.java ------- *** /tmp/sccs.oda4gl Tue Sep 16 16:35:10 2008 --- FormatData_th.java Wed Apr 16 16:55:21 2008 *************** *** 3,9 **** */ /* ! * Portions Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ --- 3,9 ---- */ /* ! * Portions Copyright 2008 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ *************** *** 31,36 **** --- 31,49 ---- * Overrides ListResourceBundle */ protected final Object[][] getContents() { + String[] dateTimePatterns = new String[] { + "H' \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 'm' \u0e19\u0e32\u0e17\u0e35 'ss' \u0e27\u0e34\u0e19\u0e32\u0e17\u0e35'", // full time pattern + "H' \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 'm' \u0e19\u0e32\u0e17\u0e35'", // long time pattern + "H:mm:ss", // medium time pattern + "H:mm' \u0e19.'", // short time pattern (modified) -- add ' \u0e19.' + // (it means something like "o'clock" in english) + "EEEE'\u0e17\u0e35\u0e48 'd MMMM G yyyy", // full date pattern + "d MMMM yyyy", // long date pattern + "d MMM yyyy", // medium date pattern + "d/M/yyyy", // short date pattern + "{1}, {0}" // date-time pattern + }; + return new Object[][] { { "MonthNames", new String[] { *************** *** 113,131 **** } }, { "sun.util.BuddhistCalendar.DateTimePatterns", ! new String[] { ! "H' \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 'm' \u0e19\u0e32\u0e17\u0e35 'ss' \u0e27\u0e34\u0e19\u0e32\u0e17\u0e35'", // full time pattern ! "H' \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 'm' \u0e19\u0e32\u0e17\u0e35'", // long time pattern ! "H:mm:ss", // medium time pattern ! "H:mm' \u0e19.'", // short time pattern (modified) -- add ' \u0e19.' ! // (it means something like "o'clock" in english) ! "EEEE'\u0e17\u0e35\u0e48 'd MMMM G yyyy", // full date pattern ! "d MMMM yyyy", // long date pattern ! "d MMM yyyy", // medium date pattern ! "d/M/yyyy", // short date pattern ! "{1}, {0}" // date-time pattern ! } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, }; } --- 126,136 ---- } }, { "sun.util.BuddhistCalendar.DateTimePatterns", ! dateTimePatterns }, + { "DateTimePatterns", + dateTimePatterns + }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, }; }
16-09-2008

EVALUATION Looks like a regression caused by the SimpleDateFormat changes for non-Gregorian calendar handling in JDK 6.
03-04-2008