You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
8.0.0-RC1: default JSON/XML DateMarshaller fails on java.sql.Date and drops .000 millis (undocumented change from 7.x) #16406
Rendering a java.sql.Date (or java.sql.Time) with as JSON / render ... as JSON works, as it does in Grails 7.x, and the default JSON date format stays yyyy-MM-dd'T'HH:mm:ss.SSS'Z' (or the change is listed in the upgrade guide).
Actual Behaviour
In 8.0.0-RC1 the default org.grails.web.converters.marshaller.json.DateMarshaller (and the XML one) formats with date.toInstant().
java.sql.Date / java.sql.Time fail. They are subclasses of java.util.Date, so supports() returns true, but java.sql.Date#toInstant() and java.sql.Time#toInstant() always throw UnsupportedOperationException (JDK contract). The converter call fails and a controller rendering the value returns 500. In 7.x the FastDateFormat path formatted them fine. java.sql.Date shows up often in maps built from groovy.sql.Sql rows or native queries.
The default output format changed. Since d3c82799f0 the default is DateTimeFormatter.ISO_INSTANT, which omits a zero fraction: a date with no milliseconds used to render as 2026-09-25T03:00:00.000Z and now renders as 2026-09-25T03:00:00Z (same for java.sql.Timestamp; dates with non-zero millis keep .123Z, so the output length now varies). Both are valid ISO 8601, but clients that parse with a fixed pattern (.SSS'Z') or compare strings break. The 8.0 upgrade guide does not mention it (the only "default date format" row is about Jackson 3).
toInstant() came in with 2fcf83213a (#15432, replacing FastDateFormat to fix the three-letter time zone warning). The format change came with d3c82799f0.
Steps To Reproduce
In any Grails 8.0.0-RC1 app, in a controller action:
render([d: java.sql.Date.valueOf('2026-09-25')] as grails.converters.JSON)
// Grails 8.0.0-RC1: RuntimeException caused by UnsupportedOperationException (HTTP 500 in a controller). Grails 7.2.3: {"d":"2026-09-25T03:00:00.000Z"} (JVM in America/Sao_Paulo)
render([d: newDate(1790305200000L)] as grails.converters.JSON)
// Grails 7.2.3: {"d":"2026-09-25T03:00:00.000Z"}// Grails 8.0.0-RC1: {"d":"2026-09-25T03:00:00Z"}
Activity
Collapse only the PR-B-safe single-type date/time marshallers
Render dates and times in JSON the same way as Spring Boot