Lenient Java 8 Date parsing

前端 未结 4 2047
無奈伤痛
無奈伤痛 2020-12-18 04:47

I\'d like to parse \'2015-10-01\' with LocalDateTime. What I have to do is

LocalDate localDate = LocalDate.parse(\'2015-10-01\');
LocalDateTime          


        
4条回答
  •  隐瞒了意图╮
    2020-12-18 05:08

    You can try

        private static final DateTimeFormatter formatter =
                    DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss").withResolverStyle(ResolverStyle.LENIENT);
    

提交回复
热议问题