[threeten-dev] SimpleDateFormat and DateTimeFormatter produce different result for JapaneseDate
Masayoshi Okutsu
masayoshi.okutsu at oracle.com
Mon Apr 29 22:52:02 PDT 2013
Hi,
This one isn't reproducible with b87. Both SimpleDateFormat and
DateTimeFormatter produce the era name in Japanese.
BTW, SimpleDateFormat and DateTimeFormatter patterns aren't compatible.
DateTimeFormatter doesn't support the text presentation of the first
year of an era, for example.
Thanks,
Masayoshi
On 4/27/2013 4:18 PM, Frank Ding wrote:
> Hi threeten guys
> Another issue was discovered in recent date time code (b87). Below
> is the test case.
>
> Locale jplocale = new Locale("ja", "JP", "JP");
> String str;
> String pattern = "GGGGyyyy\u5e74 MMMM d\u65e5";
>
> System.out.println("--- Calendar SimpleDateFormst ---");
> Calendar cal = Calendar.getInstance();
> cal.set(1989,0,8); // = Heisei 1
>
> SimpleDateFormat format = new SimpleDateFormat(pattern,
> jplocale);
> str = format.format(cal.getTime());
> System.out.println("\""+pattern+"\" "+str);
>
> System.out.println("--- JapaneseDate DateTimeFormatter ---");
> JapaneseDate date = JapaneseDate.of(1989,1,8);
> DateTimeFormatter dtf =
> DateTimeFormatter.ofPattern(pattern).withLocale(jplocale);
> str = date.format(dtf);
> System.out.println("\""+pattern+"\" "+str);
>
> The actual output is (Converted Japanese characters to Unicode by
> native2ascii command)
> > --- Calendar SimpleDateFormst ---
> > "GGGGyyyy\u5e74 MMMM d\u65e5" \u5e73\u6210\u5143\u5e74 1\u6708 8\u65e5
> > --- JapaneseDate DateTimeFormatter ---
> > "GGGGyyyy\u5e74 MMMM d\u65e5" Heisei0001\u5e74 1\u6708 8\u65e5
>
> It looks like a bug in DateTimeFormatter. Could anybody take a look
> at it and confirm?
>
> Best regards,
> Frank
>
>
More information about the threeten-dev
mailing list