JDK dateformatter parsing DayOfWeek in German locale, java8 vs java9

前端 未结 2 1136
执笔经年
执笔经年 2020-11-27 22:19

I have tried some code in Java 8 (1.8.0_77) and Java 9 (Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode))

DateTimeFormatter dtf = DateTimeFormatte         


        
2条回答
  •  春和景丽
    2020-11-27 22:43

    The abbreviatiions "Mo", "Di" etc. without dot have not disappeared in CLDR but are accessible via standalone-mode. You should change your pattern using the standalone format symbol "c" instead of "e":

    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("ccc", Locale.GERMAN);
    DayOfWeek mo = dtf.parse("Mo", DayOfWeek::from);
    

    Indeed, I consider the change of underlying data as breaking backwards compatibility (concrete as behavioural break).

提交回复
热议问题