[threeten-dev] A potential bug in JapaneseDate.of(Era era, int yearOfEra, int month, int dayOfMonth)

Frank Ding dingxmin at linux.vnet.ibm.com
Sat Apr 27 00:00:24 PDT 2013


Hi Threeten guys,
   Our Japanese test team found out a bug when calling 
JapaneseDate.of(Era era, int yearOfEra, int month, int dayOfMonth). See 
the code below.

   JapaneseDate date = 
JapaneseDate.of(java.time.chrono.JapaneseEra.HEISEI, 1, 1, 7);

   Heisei era starts in Heisei 1/1/8 which implies Heisei 1/1/7 is 
invalid.  According to its spec [1],
   It throws DateTimeException - if the value of any field is out of 
range, or if the day-of-month is invalid for the month-year, or if the 
date is not a Japanese era.
   So the correct behavior is observing DateTimeException for the code 
above.  What's your opinion of it?

Best regards,
Frank

[1] 
http://download.java.net/jdk8/docs/api/java/time/chrono/JapaneseDate.html#of%28java.time.chrono.Era,%20int,%20int,%20int%29



More information about the threeten-dev mailing list