DEV Community

ouryperd
ouryperd

Posted on

Easiest date formatting in Groovy

For years I have been formatting dates in Groovy with:

import java.text.SimpleDateFormat
println new SimpleDateFormat("yyyy-MM-dd HH.mm.ss.SSSSS Z").format(new Date())

Then I recently learned you can just do this without importing anything:

println new Date().format("yyyy-MM-dd HH.mm.ss.SSSSS Z")

Top comments (0)