How to convert a string date “2019-04-21T12:08:35” to SimpleDateFormat, there by convert to Date?

前端 未结 2 1248
甜味超标
甜味超标 2021-01-29 12:35

For normal date Strings like \"2019-04-08 08:35\"

   SimpleDateFormat df = new SimpleDateFormat(\"yyyy-dd-mm hh:mm\");

but What sh

2条回答
  •  盖世英雄少女心
    2021-01-29 13:03

    SimpleDateFormat is not a Date, it's used to

    1. Convert String to Date
    2. Format Date to String

    You can parse String to java.time.LocalDateTime directly since java8:

    LocalDateTime localDateTime = LocalDateTime.parse("2019-04-21T12:08:35");
    System.out.println(localDateTime);
    

提交回复
热议问题