How to convert two digit year to full year using Java 8 time API

前端 未结 5 1068
渐次进展
渐次进展 2021-01-17 17:41

I wish to remove the Joda-Time library from my project.

I am trying to convert a two digit year to full year. The following code from Joda-Time can fulfil the purpos

5条回答
  •  自闭症患者
    2021-01-17 18:41

    You can't create a LocalDate because the String you give doesn't provide the information needed to fill all required fields.

    You can create a Year though

    Year parsed = Year.parse("99", TWO_YEAR_FORMATTER);
    int year = parsed.getValue();
    

提交回复
热议问题