How to parse 2-digit years in Java 8 / JSR 310 / threeten.org backport?

This question relates to parsing 2-digit years in Java 8 / JSR 310 / threeten.org backport. 2-digit years is an unfortunate fact of life that you need to deal with.

My only concern is the ISO calendar. JSR 310 defaults to a 2000 “base year” for two-digit years.

I see that base year management is available through

DateTimeFormatterBuilder.appendValueReduced(...)

Template formats provide a convenient mechanism for specifying date formats.

dd-MMM-yy
M/d/yy
d/M/yy

I do not see the mechanism for applying the “base year” for two-year years after applying the format template.

Joda-time had DateTimeFormatter.withPivotYear(int pivotYear)as a mechanism to solve this problem.

  • Does JSR 310 have a mechanism for applying a base for a 2-digit year after specifying a pattern?

  • , 2000?

+4

All Articles