Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6683975
Votes 1
Synopsis [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
Category java:classes_text
Reported Against
Release Fixed 7(b46), 6u12(b01) (Bug ID:2167790)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6769873
Submit Date 03-APR-2008
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.
Posted Date : 2008-04-03 16:32:34.0
Work Around
N/A
Evaluation
Looks like a regression caused by the SimpleDateFormat changes for non-Gregorian calendar handling in JDK 6.
Posted Date : 2008-04-03 23:25:53.0
Comments
  
  Include a link with my name & email   

Submitted On 15-APR-2008
Madruguinha
We've realized the same problem using the "zh" locale, where using SimpleDateFormat we get "MMM, dd yy" and using JSTL we get "dd/MM/yyyy"



PLEASE NOTE: JDK6 is formerly known as Project Mustang