Reputation: 141
I need to be able to timestamp things in this format:
2018-01-26T10:47:44.686000-08:00
I am not sure how exactly to do this - and having trouble following the docs
Upvotes: 1
Views: 202
Reputation: 4482
Or just the groovy format
extension to the java.util.Date class:
def date = new Date()
println(date.format("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"))
Upvotes: 1
Reputation: 3370
You may want to take a look at the SimpleDateFormat API: https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
For example, a formatter like you mentioned above would be:
def df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ")
println df.format(new Date())
Upvotes: 0