gpt4 book ai didi

java - 无法在 GWT 中将字符串转换为日期

转载 作者:太空宇宙 更新时间:2023-11-04 06:56:19 25 4
gpt4 key购买 nike

我正在尝试将 GWT 中的字符串更改为日期。在 StackOverFlow 中搜索后,我得到了一个解决方案。但我仍然得到

java.lang.IllegalArgumentException: Fri Feb 21 00:00:00 IST 2014

下面是我在 GXT GridEditor 类中的代码。

DateTimeFormat fmt = DateTimeFormat.getFormat("EEE MMM dd HH:mm:ss z yyyy");
Date checkInDate = fmt.parse(ACCCheckBoxModel.getSelectedItem().getCheckinDate());

来自 ACCCheckBoxModel.getSelectedItem().getCheckinDate()我得到一个字符串。我需要将此字符串转换为日期。然后我需要将日期格式转换为 dd/MMM/yyyy格式。

请建议如何解决此问题。

最佳答案

解析器不理解 IST。尝试将解析移至服务器端。

以下引文来自 API-Doc :

The time zone support for parsing is limited. Only standard GMT and RFC format are supported. Time zone specification using time zone id (like America/Los_Angeles), time zone names (like PST, Pacific Standard Time) are not supported. Normally, it is too much a burden for a client application to load all the time zone symbols. And in almost all those cases, it is a better choice to do such parsing on server side through certain RPC mechanism. This decision is based on particular use cases we have studied; in principle, it could be changed in future versions.

关于java - 无法在 GWT 中将字符串转换为日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22703440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com