问题
I am running Grails 3.3.8 with Java 8.v181.
I have a included hibernate-java8 and grails-java8 plugins, in build.gradle
//needed for java local datetime features set
compile "org.grails.plugins:grails-java8"
compile "org.hibernate:hibernate-java8"
I have a domain class like this
import cmdb.Customer
import java.time.LocalDateTime
class ServiceRequest {
//Long id
String requestIdentifier
Customer customer
String customerSummary
String status
LocalDateTime dateCreated = LocalDateTime.now()
LocalDateTime requiredDate
LocalDateTime authorisedDate
String contactDetails
String priority = "normal"
BillOfMaterials bom
String toString() {
"ServiceRequest (id:$id, customer:$customerSummary, status:$status)"
}
static constraints = {
requestIdentifier size:3..30, unique:true, nullable:false
customer nullable:true
customerSummary nullable:true
status nullable :false
dateCreated nullable:false
requiredDate nullable:true
authorisedDate nullable:true
contactDetails nullable:true
priority nullable:true
bom nullable:true
}
}
When you run that att with default controller and scaffolding views all you get is this - there is no rendering for datetime.
The dbconsole shows that defaulting mapping into jdbc is using H2 timestamp type and the dateCreated is persisted - but doesn't show in the form. the other two localdatetime do - but have no rende4ering in the list view and you cant edit in the edit form
Using older Date format - does render a time field selector - is localdatetime still not supported in GSP views, even with Java8 support enabled?
It is frustrating to have to drop back to use Date for views as my other entities/DT objects etc are using localdatetime.
来源:https://stackoverflow.com/questions/52589049/how-do-you-get-grails-gsp-support-for-java-localdatetime