Joda ライブラリを使用すると、次のことができます
DateTimeFormat.forPattern("yyyy").parseLocalDate("2008")
2008 年 1 月 1 日に LocalDate を作成する
Java8を使用すると、次のことができます
LocalDate.parse("2008",DateTimeFormatter.ofPattern("yyyy"))
しかし、それは解析に失敗します:
Text '2008' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {Year=2008},ISO of type java.time.format.Parsed
具体的に sth のように書く代わりに、代替手段はありますか
LocalDate.ofYearDay(Integer.valueOf("2008"), 1)
?