[threeten-dev] Review Lenient parsing of 2 and 4 digits values (years)
roger riggs
roger.riggs at oracle.com
Fri Apr 19 11:26:34 PDT 2013
Hi,
As noted in#218 Parsing 2 and 4 digit years
<https://github.com/ThreeTen/threeten/issues/218>, the reducedValue parsing
lenient mode should be defined to allow parsing of absolute values
greater than the defined field width.
Webrev:
http://cr.openjdk.java.net/~rriggs/webrev-lenient-parse-218/
Modified DateTimeFormatter.appendValueReduced to define the behavior
when isLenient.
Modified NumberPrinterParser in lenient mode to accept 1..19 digits.
Note, the API/ implementation only works for base < MAX_INT, ~ 10 digits
but the field size may be defined larger.
Removed width constraint for "fixed" fields unless strict.
Modified ReducedPrinterParser.setValue to apply the base only
if isStrict or the value is less than range.
It is not possible to enter negative values since ReducedPrinterParser
prohibits any sign character. It should be considered to make the
sign parsing lenient also. Currently entering a sign is prohibited in a
"fixed"
length field. The definition of fixed is diluted in this case in lenient
mode.
It is also not possible to enter absolute values less than the width.
All small values are considered to be combined with the base.
The only interesting case though is year and the range of likely base
values is the current or past centuries.
Thanks, Roger
More information about the threeten-dev
mailing list