[threeten-dev] SimpleDateFormat and DateTimeFormatter produce different result for JapaneseDate

Stephen Colebourne scolebourne at joda.org
Mon Apr 29 23:59:14 PDT 2013


Functionality available in SDF but not in DateTimeFormatter sounds
like a bug. Perhaps you should raise an issue for any differences you
know of?

Stephen


On 30 April 2013 06:52, Masayoshi Okutsu <masayoshi.okutsu at oracle.com> wrote:
> 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