[threeten-dev] Review Lenient parsing of 2 and 4 digits values (years)
Xueming Shen
xueming.shen at oracle.com
Fri Apr 19 12:20:26 PDT 2013
I'm a little concerned of the approach of using the reducedValue parsing/lenient
mode to address this 2 and 4 digits values issues, especially it introduces in the
"uncertainty of" adding the baseValue or not based on the width of the input value,
while the method itself is originally designed to add the baseValue for a "reduced"
input. There is also words later says "This is a fixed width parser operating using
'adjacent value parsing'...", anything need to be wording here?
-Sherman
On 04/19/2013 11:26 AM, roger riggs wrote:
> 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