Parse time with microseconds in Java

后端 未结 3 333
情深已故
情深已故 2021-01-19 02:40

I am having problems parsing time strings in Java that are in the format of 2013-01-09 09:15:03.000000. In my data, the last three digits are always 0 (meaning

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 03:00

    try java.sql.Timestamp

         Timestamp ts = Timestamp.valueOf("2013-01-09 09:15:03.500000"); 
         Date date = new Date(ts.getTime())
    

    it's also thread-safe and fast as opposed to SimpleDateFormat

提交回复
热议问题