Skip to content

Conversation

@codeconsole
Copy link
Contributor

@codeconsole codeconsole commented Oct 22, 2025

Alternative solution for <f:all rendering of date objects with time precision.

NOTE: This proposal puts rendering IN SYNC with create/edit input tag rendering. Currently the fields plugin ONLY supports MINUTE precision for input rendering using the date picker.

The documentation for datePicker is incorrect. "and second of the day." Seconds have never been supported, but are set to be added in with #15118

Show DateTime - Proposal (contingent on Locale)

Type Value
Calendar 10/8/25, 12:48 AM
Instant 10/8/25, 12:48 AM
Offset Date Time 10/8/25, 12:48 AM
Zoned Date Time 10/8/25, 12:48 AM
Date 10/8/25, 12:48 AM
SQL Date 10/8/25
Time 12:48 AM
Local Time 12:48 AM
Timestamp 10/8/25, 12:48 AM
Local Date 10/8/25
Local Date Time 10/8/25, 12:48 AM

Show DateTime - Current Behavior

Type Value
Calendar 2025-10-08 00:48:46 PDT
Instant 2025-10-08 00:48:46 PDT
Offset Date Time 2025-10-08 00:48:46 PDT
Zoned Date Time 2025-10-08 00:48:46 PDT
Date 2025-10-08 00:48:46 PDT
SQL Date 10/8/25
Time 12:48 AM
Local Time 12:48 AM
Timestamp 2025-10-08 00:48:46 PDT
Local Date 10/8/25
Local Date Time 2025-10-08 00:48:46 PDT

@matrei
Copy link
Contributor

matrei commented Oct 23, 2025

So, if I understand this correctly, before this change, the date.format and default.date.format message properties were used to decide the formatting. Now, it will always use FormatStyle.SHORT for both date and time + timezone.

Also, should all these types be formatted with timezone?

@codeconsole
Copy link
Contributor Author

So, if I understand this correctly, before this change, the date.format and default.date.format message properties were used to decide the formatting. Now, it will always use FormatStyle.SHORT for both date and time + timezone.

Also, should all these types be formatted with timezone?

@matrei this ticket will be for coming up with a final solution
#15164

I described the current behavior there:

switch (model.type) {
case Boolean.TYPE:
case Boolean:
g.formatBoolean(boolean: model.value)
break
case LocalDate:
case java.sql.Date:
g.formatDate(date: model.value, type: 'DATE')
break
case java.sql.Time:
case LocalTime:
g.formatDate(date: model.value, type: 'TIME')
break
case Calendar:
case Date:
case LocalDateTime:
case java.sql.Timestamp:
case Instant:
case ZonedDateTime:
case OffsetDateTime:
g.formatDate(date: model.value)
break
default:
g.fieldValue(bean: model.bean, field: model.property)
}

currently g.formatDate(date: model.value) is called which result in no type so that results in a default format:

format = messageHelper('date.format', { messageHelper('default.date.format', 'yyyy-MM-dd HH:mm:ss z', null, locale) }, null, locale)

all this ticket does is set the type to datetime which results in the following behavior;

if (type == 'DATE') {
dateFormat = grailsTagDateHelper.getDateFormat(dateStyle, timeZone, locale)
}
else if (type == 'TIME') {
dateFormat = grailsTagDateHelper.getTimeFormat(timeStyle, timeZone, locale)
}
else { // 'both' or 'datetime'
dateFormat = grailsTagDateHelper.getDateTimeFormat(dateStyle, timeStyle, timeZone, locale)
}

Copy link
Contributor

@matrei matrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried out this change and it seems to be a real improvement to the current rendering behavior.

Thanks @codeconsole!

@jdaugherty jdaugherty merged commit 0b1d127 into apache:7.0.x Oct 24, 2025
36 checks passed
@jamesfredley jamesfredley added this to the grails:7.0.1 milestone Oct 28, 2025
@jamesfredley jamesfredley moved this to Done in Apache Grails Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants