[threeten-dev] Lenient parsing of 2 and 4 digits values
roger riggs
roger.riggs at oracle.com
Mon Apr 22 15:18:57 PDT 2013
Hi,
An alternative to the strict/lenient proposal with better/cleaner
semantics is to
modify appendValueReduced to be a variable width numeric field and treat it
very similarly to NumberPrinterParser.
If the min == max, it has the current behavior. If max > min, then it
uses the adjacent
parsing mode to update the subsequentWidth value if followed by fixed width
fields but can then parse additional digits.
The number of digits supplied as input is used to do the substitution into
the base value. If the number of digits input is the same as the number
of digits
in the base value then the baseValue is not used.
The strict/lenient mode is not necessary, the min/max width values are
sufficient
to control the parsing. Similarly, formatting can be conditioned to output
the reduce value to fill the minimum width unless the actual value cannot be
represented accurately and then the full value can be output up to the
max field width.
The updated webrev and tests illustrate this approach.
This this idea is viable, some additional cleanup work is needed to
expand and
reorganize the tests and cleanup the implementation and description.
Webrev:
http://cr.openjdk.java.net/~rriggs/webrev-lenient-parse-218/
Please comment.
Roger
More information about the threeten-dev
mailing list