Groovy web console

subscribe to the feed Subscribe
to this
site
date parsers (via #groovywebconsole)
tweet this snippet Tweet
this
script

date parsers

Published 1 month ago by gstv with tags SimpleDateFormat
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.text.SimpleDateFormat
println new SimpleDateFormat("yyyy-MM-dd").parse("2019-01-01")
println new SimpleDateFormat("yyyy-mm-dd").parse("2019-01-01")
println new SimpleDateFormat("y-M-d").parse("2019-01-01")
println new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").parse("2019-01-01 00:00:00.0")
println new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'").parse("2019-01-01T00:00:00Z")
println new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'").parse("2019-01-01T00:00:00.000Z")
println new SimpleDateFormat("yyyyMMdd HH:mm").parse("20190101 00:00")
println new SimpleDateFormat("yyyyMMdd HH:mm").parse("2019-01-01")