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

前端 未结 2 1249
甜味超标
甜味超标 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);
    
    0 讨论(0)
  • 2021-01-29 13:17

    Before Java8 :

    SimpleDateFormat df = new SimpleDateFormat("yyyy-dd-yy'T'hh:mm:ss");
    
    0 讨论(0)
提交回复
热议问题