This message was deleted.
# questions
s
This message was deleted.
1
r
This sounds like a Java question rather than a Grails question - you might find it helpful to look at the Java Data Time classes: https://docs.oracle.com/javase/tutorial/datetime/TOC.html
It looks as though the REST API is returning dates in ISO 8601 format, which is a universal and unambiguous way of representing dates and times - you need to convert an ISO 8601 string into a date and time string formatted according to the local conventions, which vary betweem countries: https://en.wikipedia.org/wiki/ISO_8601
You basically need to use a
java.time.format.DateFormatter
object to convert what looks like an ISO_INSTANT date and time into something more readable such as an RFC_1123_DATE_TIME: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
a
I solved adding
Copy code
implementation "org.codehaus.groovy:groovy-dateutils:3.0.19"
Into build.gradle and modify my gson view like:
Copy code
json {
    date mydate.format('dd-MM-yy HH:mm')
}
And works fine
r
The
groovy-dateutil
module is based on Java's legacy Date and Calendar types - it might better to use the
groovy-datetime module
, which supports working with the new Date/Time API https://groovy-lang.org/groovy-dev-kit.html#_working_with_datetime_types
a
This version is not compatible with groovy 3 and grails 5, maybe it will be compatible with grails 6