Groovy date format for UTC with milliseconds

前端 未结 3 970
后悔当初
后悔当初 2021-01-07 17:35

I\'m having trouble finding a good way of formatting a UTC-time stamp with this format: yyyyMMdd-HH:mm:ss.

I wasn\'t able

3条回答
  •  春和景丽
    2021-01-07 18:22

    You can try this:

    TimeZone.getTimeZone('UTC')
    Date date = new Date()
    String newdate = date.format("YYYY-MM-dd HH:mm:ss.Ms")
    log.info newdate
    

提交回复
热议问题