loading...

Easiest date formatting in Groovy

ou_ryperd profile image ouryperd ・1 min read

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")

Discussion

markdown guide