[threeten-dev] It looks ResolverStyle.LEINENT does not work as description in javadoc

roger riggs roger.riggs at oracle.com
Fri May 10 08:48:48 PDT 2013


Hi Patrick,

The javadoc for ISOChronology.resolveDate does seem to indicate that
a month of 15 should be allowed LENIENT mode; so its a bug.

"    *  If the mode is lenient, then the date is combined in a manner 
equivalent to
      *  creating a date on the first of January in the requested year, 
then adding
      *  the difference in months, then the difference in days.
"

BTW, the descriptions in ResolveStyle give only a general description of
the mode  the Chronology.resolveDate method should have the definitive 
behavior.

Roger

On 5/10/2013 4:25 AM, Patrick Zhang wrote:
> Hi Team,
>
> ==================
>
> public static finalResolverStyle 
> <http://sqeweb.us.oracle.com/jsn/users/patrick/threeten/build/linux-x86-normal-server-release/docs/api/java/time/format/ResolverStyle.html> 
> LENIENT
>
> Style to resolve dates and times leniently.
>
> Using lenient resolution will resolve the values in an appropriate 
> lenient manner. Individual fields will interpret this differently.
>
> For example, lenient mode allows the month in the ISO calendar system 
> to be outside the range 1 to 12. For example, month 15 is treated as 
> being 3 months after month 12.
> ==================
>
> My simple test code:
> ==================
>                 DateTimeFormatterBuilder builder = new 
> DateTimeFormatterBuilder();
>                 DateTimeFormatter formatter1 = 
> builder.appendValue(ChronoField.YEAR).appendLiteral("-")
> .appendValue(ChronoField.MONTH_OF_YEAR).appendLiteral("-")
> .appendValue(ChronoField.DAY_OF_MONTH)
> .toFormatter();
> //              formatter1.withResolverStyle(ResolverStyle.SMART);
> //              System.out.println(formatter1.parse("2000-2-30"));
>
> formatter1.withResolverStyle(ResolverStyle.LENIENT);
> System.out.println(formatter1.parse("2000-15-30"));
> ==================
> I expect eagerly it will print sth like "2001-03-30" or "2000-03-30". :)
> But it throws exception. Do I make any mistake here?
>
> FYI, ResolverStyle.SMART will parse "2000-2-30" to "2000-02-29" 
> correctly.
>
> Regards
> Patrick
>
>



More information about the threeten-dev mailing list