parsing - Parse a two-digit year as 1900s rather than 2000s in java.time? -
this question has answer here:
the java.time framework built java 8 , later parses two-digit year strings being in 2000s. 90
becomes 2090
.
from java.time.datetimeformatter
class documentation:
if count of letters two… parse using base value of 2000, resulting in year within range 2000 2099 inclusive.
i have data values such 90
meant 1990
.
how can change pivot year parsing two-digit year strings 1900
rather 2000
?
even better, how can set arbitrary pivot year, know data sources have rules partial century. example, “if under 80
, assume 2000s, otherwise assume 1900s”.
yes, know, using two-digit year values dopey. data not under control.
just use api value in 2000-2099 range , use conditionals rest of work. don't worry trying change api itself.
Comments
Post a Comment