简体   繁体   English

将日期发送到Grails时,GORM默认日期格式

[英]GORM default Date format when sending date to Grails

I am sending a JSON PUT request to Grails. 我正在向Grails发送JSON PUT请求。 In the JSON object, I have a date string. 在JSON对象中,我有一个日期字符串。 I have searched and experimented, but I cannot determine the default date string format that GORM wants to parse the date string. 我已经进行了搜索和试验,但是我无法确定GORM想要解析日期字符串的默认日期字符串格式。 In all my attempts I get the following error: 在所有尝试中,我遇到以下错误:

java.lang.IllegalArgumentException: Could not parse date: Unparseable date java.lang.IllegalArgumentException:无法解析日期:无法解析的日期

I just want to know the default format GORM expects and I will happily format the date string in that format before sending it to the server. 我只是想知道GORM期望的默认格式,因此我很乐意将日期字符串格式化为该格式,然后再将其发送到服务器。

I suppose you face this issue during data binding. 我想您在数据绑定期间会遇到此问题。

Reason: 原因:
Default date format for binding is yyyy-MM-dd HH:mm:ss.S 绑定的默认日期格式为yyyy-MM-dd HH:mm:ss.S

Solution: 解:
The default data format can be changed using PropertyEditorRegistrar . 可以使用PropertyEditorRegistrar更改默认数据格式。 Follow this for details. 有关详细信息,请遵循

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM