小编Gow*_*esa的帖子

final static LocalDateTime retrieving from another class is throwing java.lang.ExceptionInInitializerError

I have a variable MINDATE in MyConstants file. You can see the declaration below.

public static final LocalDateTime MINDATE =  LocalDateTime.of(LocalDate.of(2011, 1, 1), LocalTime.MIDNIGHT);
Run Code Online (Sandbox Code Playgroud)

I am consuming this variable in another class just by using MyConstants.MINDATE then I get the following exception

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.cw.na.vos.DateTest.main(DateTest.java:14)
Caused by: java.lang.IllegalArgumentException: Unknown pattern letter: T
    at java.time.format.DateTimeFormatterBuilder.parsePattern(Unknown Source)
    at java.time.format.DateTimeFormatterBuilder.appendPattern(Unknown Source)
    at java.time.format.DateTimeFormatter.ofPattern(Unknown Source)
    at com.cw.na.vos.MyConstants.<clinit>(MyConstants.java:228)
    ... 1 more
Run Code Online (Sandbox Code Playgroud)

I am unable to understand the reason behind it.

public …
Run Code Online (Sandbox Code Playgroud)

java datetime exception java-time localdate

0
推荐指数
1
解决办法
274
查看次数

标签 统计

datetime ×1

exception ×1

java ×1

java-time ×1

localdate ×1