You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "codeconsole (via GitHub)" <gi...@apache.org> on 2025/10/08 07:08:09 UTC
[PR] Use consistent ISO-8601 formatting for rendering JSON Date, LocalDateTime, and Instant properties [grails-core]
codeconsole opened a new pull request, #15121:
URL: https://github.com/apache/grails-core/pull/15121
Fixes #15119
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#discussion_r2414061382
##########
grails-converters/src/main/groovy/org/grails/web/converters/configuration/ConvertersConfigurationInitializer.java:
##########
@@ -112,6 +112,12 @@ private void initJSONConfiguration() {
}
marshallers.add(new org.grails.web.converters.marshaller.json.DateMarshaller());
}
+ marshallers.add(new org.grails.web.converters.marshaller.json.CalendarMarshaller());
Review Comment:
All of this would technically be a breaking change from past versions. I think we should ship the marshallers as part of post 7.0.0 but remove this default until 8.x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#issuecomment-3382601286
Per weekly meeting, we'll merge after @matrei reviews.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#issuecomment-3380112426
@codeconsole Please see why the Code style fails
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on code in PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#discussion_r2415880312
##########
grails-converters/src/main/groovy/org/grails/web/converters/marshaller/json/ZonedDateTimeMarshaller.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.grails.web.converters.marshaller.json;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import grails.converters.JSON;
+import org.grails.web.converters.exceptions.ConverterException;
+import org.grails.web.converters.marshaller.ObjectMarshaller;
+import org.grails.web.json.JSONException;
+
+/**
+ * JSON ObjectMarshaller which converts a ZonedDateTime to ISO-8601 format with timezone offset.
+ *
+ * @since 7.0
+ */
+public class ZonedDateTimeMarshaller implements ObjectMarshaller<JSON> {
+
+ public boolean supports(Object object) {
+ return object instanceof ZonedDateTime;
+ }
+
+ public void marshalObject(Object object, JSON converter) throws ConverterException {
+ try {
+ ZonedDateTime zonedDateTime = (ZonedDateTime) object;
+ converter.getWriter().value(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(zonedDateTime));
Review Comment:
Add comment why we are using `ISO_OFFSET_DATE_TIME` instead of `ISO_ZONED_DATE_TIME` formatter?
##########
grails-views-gson/src/main/groovy/grails/plugin/json/converters/ZonedDateTimeJsonConverter.groovy:
##########
@@ -41,6 +41,6 @@ class ZonedDateTimeJsonConverter implements JsonGenerator.Converter {
@Override
Object convert(Object value, String key) {
- DateTimeFormatter.ISO_ZONED_DATE_TIME.format((ZonedDateTime) value)
+ DateTimeFormatter.ISO_OFFSET_DATE_TIME.format((ZonedDateTime) value)
Review Comment:
Add comment why we are using `ISO_OFFSET_DATE_TIME` instead of `ISO_ZONED_DATE_TIME` formatter?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on code in PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#discussion_r2417464134
##########
grails-views-gson/src/main/groovy/grails/plugin/json/converters/ZonedDateTimeJsonConverter.groovy:
##########
@@ -41,6 +41,6 @@ class ZonedDateTimeJsonConverter implements JsonGenerator.Converter {
@Override
Object convert(Object value, String key) {
- DateTimeFormatter.ISO_ZONED_DATE_TIME.format((ZonedDateTime) value)
+ DateTimeFormatter.ISO_OFFSET_DATE_TIME.format((ZonedDateTime) value)
Review Comment:
@matrei in order to match Spring Boot Jackson output:
```
ZonedDateTime value = ZonedDateTime.now()
println DateTimeFormatter.ISO_ZONED_DATE_TIME.format((ZonedDateTime) value)
println DateTimeFormatter.ISO_OFFSET_DATE_TIME.format((ZonedDateTime) value)
```
```
2025-10-09T17:27:04.791062156Z[UTC]
2025-10-09T17:27:04.791062156Z
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#issuecomment-3381332611
This is a breaking change and we did not plan to do another RC. We need to discuss this PR at the weekly to merge it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#issuecomment-3387806334
```json
{
"platform": "Grails 7.0.0-SNAPSHOT",
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46.407Z",
"calendar": "2025-10-08T07:48:46.407Z",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"dateTime": {
"calendar": "2025-10-08T07:48:46.407Z",
"date": "2025-10-08T07:48:46.407Z",
"instant": "2025-10-08T07:48:46.407254Z",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00"
}
}
```
```json
{
"platform": "Grails 7.0.0-SNAPSHOT (gson)",
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46Z",
"calendar": "2025-10-08T07:48:46Z",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00",
"dateTime": {
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46Z",
"calendar": "2025-10-08T07:48:46Z",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00"
}
}
```
```json
{
"platform": "Spring Boot 3.5.6",
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46.407+00:00",
"calendar": "2025-10-08T07:48:46.407+00:00",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00",
"dateTime": {
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46.407+00:00",
"calendar": "2025-10-08T07:48:46.407+00:00",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00"
}
}
```
```json
{
"platform": "Spring Boot 4.0.0-M3",
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46.407Z",
"calendar": "2025-10-08T07:48:46.407Z",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00",
"dateTime": {
"instant": "2025-10-08T07:48:46.407254Z",
"date": "2025-10-08T07:48:46.407Z",
"calendar": "2025-10-08T07:48:46.407Z",
"localDate": "2025-10-08",
"localDateTime": "2025-10-08T00:48:46.407254",
"offsetDateTime": "2025-10-08T00:48:46.407254-07:00",
"zonedDateTime": "2025-10-08T00:48:46.407254-07:00"
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on code in PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#discussion_r2417464134
##########
grails-views-gson/src/main/groovy/grails/plugin/json/converters/ZonedDateTimeJsonConverter.groovy:
##########
@@ -41,6 +41,6 @@ class ZonedDateTimeJsonConverter implements JsonGenerator.Converter {
@Override
Object convert(Object value, String key) {
- DateTimeFormatter.ISO_ZONED_DATE_TIME.format((ZonedDateTime) value)
+ DateTimeFormatter.ISO_OFFSET_DATE_TIME.format((ZonedDateTime) value)
Review Comment:
@matrei in order to match Spring Boot Jackson output:
```
ZonedDateTime value = ZonedDateTime.now()
println DateTimeFormatter.ISO_ZONED_DATE_TIME.format((ZonedDateTime) value)
println DateTimeFormatter.ISO_OFFSET_DATE_TIME.format((ZonedDateTime) value)
```
```
2025-10-09T17:27:04.791062156Z[UTC]
2025-10-09T17:27:04.791062156Z
```
Spring Boot produces "zonedDateTime": "2025-10-08T00:48:46.407254-07:00",
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#discussion_r2414061382
##########
grails-converters/src/main/groovy/org/grails/web/converters/configuration/ConvertersConfigurationInitializer.java:
##########
@@ -112,6 +112,12 @@ private void initJSONConfiguration() {
}
marshallers.add(new org.grails.web.converters.marshaller.json.DateMarshaller());
}
+ marshallers.add(new org.grails.web.converters.marshaller.json.CalendarMarshaller());
Review Comment:
All of this would technically be a breaking change from past versions. I think we should ship the marshallers as part of 7.0.1 but remove this default until 8.x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on code in PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#discussion_r2417467090
##########
grails-converters/src/main/groovy/org/grails/web/converters/marshaller/json/ZonedDateTimeMarshaller.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.grails.web.converters.marshaller.json;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import grails.converters.JSON;
+import org.grails.web.converters.exceptions.ConverterException;
+import org.grails.web.converters.marshaller.ObjectMarshaller;
+import org.grails.web.json.JSONException;
+
+/**
+ * JSON ObjectMarshaller which converts a ZonedDateTime to ISO-8601 format with timezone offset.
+ *
+ * @since 7.0
+ */
+public class ZonedDateTimeMarshaller implements ObjectMarshaller<JSON> {
+
+ public boolean supports(Object object) {
+ return object instanceof ZonedDateTime;
+ }
+
+ public void marshalObject(Object object, JSON converter) throws ConverterException {
+ try {
+ ZonedDateTime zonedDateTime = (ZonedDateTime) object;
+ converter.getWriter().value(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(zonedDateTime));
Review Comment:
@matrei see comment above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole merged PR #15121:
URL: https://github.com/apache/grails-core/pull/15121
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use consistent ISO-8601 formatting for rendering JSON Date, Calendar, LocalDateTime, and Instant properties [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15121:
URL: https://github.com/apache/grails-core/pull/15121#issuecomment-3380138373
> @codeconsole Please see why the Code style fails
I forgot to commit the newly added Calendar marshaller.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org