How to get year, month, day, hours, minutes, seconds and milliseconds of the current moment in Java?

后端 未结 10 1976
渐次进展
渐次进展 2020-11-29 16:58

How can I get the year, month, day, hours, minutes, seconds and milliseconds of the current moment in Java? I would like to have them as Strings.

10条回答
  •  没有蜡笔的小新
    2020-11-29 17:24

    in java 7 Calendar one line

    new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(Calendar.getInstance().getTime())
    

提交回复
热议问题