The java.time framework built into Java 8 and later parses two-digit year strings as being in the 2000s. So 90
becomes 2090
.
From the java.time.DateTimeFormatter
class documentation:
If the count of letters is two… will parse using the base value of 2000, resulting in a year within the range 2000 to 2099 inclusive.
I have data where values such as 90
meant 1990
.
How can I change the pivot year for parsing two-digit year strings to 1900
rather than 2000
?
Even better, how can I set any arbitrary pivot year, as I know some data sources have rules for partial century. For example, “If under 80
, assume 2000s, otherwise assume 1900s”.
Yes, I know, using two-digit year values is dopey. But the data was not under my control.