M06H
M06H

Reputation: 1783

Java Freemarker template datetime in correct format

I am using https://freemarker.apache.org/ library in my java application to populate xml. For creation time I am unable to get it as expect (see below):

Expected:

<creationTimestamp>2019-10-07T09:09:54.786Z</creationTimestamp>

Actual:

<creationTimestamp>2019-10-08T19:38:35+01:00</creationTimestamp>

I am using <creationTimestamp>${.now?datetime?iso_local}</creationTimestamp>. How can I display the timestamp as expected and is there a way? Or, what would be Java 8 way LocalDateTime of doing this if not possible with expression?

Upvotes: 0

Views: 319

Answers (1)

M06H
M06H

Reputation: 1783

Basic formats:
${aDate?iso_utc}
${aTime?iso_utc}
${aDateTime?iso_utc}


Basic formats:
2011-05-16
21:32:13Z
2011-05-16T21:32:13Z

iso_utc gives the result as expected.

Upvotes: 1

Related Questions