GORM默认日期格式发送日期到Grails [英] GORM default Date format when sending date to Grails

查看:733
本文介绍了GORM默认日期格式发送日期到Grails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向Grails发送JSON PUT请求。在JSON对象中,我有一个日期字符串。我已经搜索并尝试了,但我无法确定GORM要解析日期字符串的默认日期字符串格式。在我所有的尝试中,我收到以下错误:



java.lang.IllegalArgumentException:无法解析日期:不可稀释的日期



我只想知道GORM预期的默认格式,在发送到服务器之前,我会很乐意格式化该格式的日期字符串。

解决方案

我想你在数据绑定时遇到这个问题。



原因:

默认日期格式绑定是 yyyy-MM-dd HH:mm:ss.S



解决方案: strong>

可以使用 PropertyEditorRegistrar 。请按照了解详情。


I am sending a JSON PUT request to Grails. In the JSON object, I have a date string. I have searched and experimented, but I cannot determine the default date string format that GORM wants to parse the date string. In all my attempts I get the following error:

java.lang.IllegalArgumentException: Could not parse date: Unparseable date

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.

解决方案

I suppose you face this issue during data binding.

Reason:
Default date format for binding is yyyy-MM-dd HH:mm:ss.S

Solution:
The default data format can be changed using PropertyEditorRegistrar. Follow this for details.

这篇关于GORM默认日期格式发送日期到Grails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆