Java date is not preserving milliseconds in conversion with simple date format

前端 未结 5 1639
死守一世寂寞
死守一世寂寞 2021-01-19 01:32

I\'m trying to convert the following string \"2012-04-13 04:08:42.794\" to a date type:

    SimpleDateFormat dateFormat = new SimpleDateFormat(\         


        
5条回答
  •  借酒劲吻你
    2021-01-19 02:11

    Instead of printing using toString() you can make your own printing method, so it prints the information you want specifically. Also note that most of the Date class is deprecated - look at http://docs.oracle.com/javase/6/docs/api/java/util/Date.html

提交回复
热议问题