Convert java.util.Date to String

前端 未结 18 2275
悲&欢浪女
悲&欢浪女 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:59

    Commons-lang DateFormatUtils is full of goodies (if you have commons-lang in your classpath)

    //Formats a date/time into a specific pattern
     DateFormatUtils.format(yourDate, "yyyy-MM-dd HH:mm:SS");
    

提交回复
热议问题