Convert java.util.Date to String

前端 未结 18 2540
悲&欢浪女
悲&欢浪女 2020-11-22 05:37

I want to convert a java.util.Date object to a String in Java.

The format is 2010-05-30 22:15:52

18条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 05:50

    The easiest way to use it is as following:

    currentISODate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss", "2013-04-14T16:11:48.000");
    

    where "yyyy-MM-dd'T'HH:mm:ss" is the format of the reading date

    output: Sun Apr 14 16:11:48 EEST 2013

    Notes: HH vs hh - HH refers to 24h time format - hh refers to 12h time format

提交回复
热议问题