Skip to content

Commit

Permalink
LocalDate and LocalDateTime support
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconsole committed Jan 12, 2025
1 parent 03b36e3 commit 1d1bbaf
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import org.springframework.web.servlet.LocaleResolver
import jakarta.servlet.http.HttpServletRequest
import java.sql.Blob
import java.text.NumberFormat
import java.time.LocalDate
import java.time.LocalDateTime

import static FormFieldsTemplateService.toPropertyNameFormat

Expand Down Expand Up @@ -712,7 +714,7 @@ class FormFieldsTagLib {
return renderAssociationInput(model, attrs)
} else if (oneToMany) {
return renderOneToManyInput(model, attrs)
} else if (model.type in [Date, Calendar, java.sql.Date, java.sql.Time]) {
} else if (model.type in [Date, Calendar, java.sql.Date, java.sql.Time, LocalDate, LocalDateTime]) {
return renderDateTimeInput(model, attrs)
} else if (model.type in [byte[], Byte[], Blob]) {
return g.field(attrs + [type: "file"])
Expand All @@ -726,7 +728,7 @@ class FormFieldsTagLib {


CharSequence renderDateTimeInput(Map model, Map attrs) {
attrs.precision = model.type == java.sql.Time ? "minute" : "day"
attrs.precision = (model.type == java.sql.Time || java.time.LocalDate)? "minute" : "day"
if (!model.required) {
attrs.noSelection = ["": ""]
attrs.default = "none"
Expand Down Expand Up @@ -915,6 +917,8 @@ class FormFieldsTagLib {
case Date:
case java.sql.Date:
case java.sql.Time:
case LocalDate:
case LocalDateTime:
g.formatDate(date: model.value)
break
default:
Expand Down

0 comments on commit 1d1bbaf

Please sign in to comment.