[英]Struts2 Date Tag TimeZone behavior
I am using <s:date>
tag of struts2. 我正在使用struts2的
<s:date>
标记。
To convert a date stored 04/09/2014 11:40:17
in UTC time to IST
time I used struts2 date
tag as belows : 要将UTC时间中存储的
04/09/2014 11:40:17
的日期转换为IST
时间,我使用了struts2 date
标记,如下所示:
<s:date name = "dateregistered"
format = "MM/dd/yyyy HH:mm:ss a"
timezone = "GMT+5.30" />
and it always give me the date: 04/09/2014 06:10:17 AM
. 而且它总是给我日期:
04/09/2014 06:10:17 AM
。
The expected result should be: 04/09/2014 05:10:17 PM
. 预期结果应为:
04/09/2014 05:10:17 PM
。
I am not getting where I am wrong and doing mistake,I am using hibernate
to fetch and java.util.date
to store the value which is used above 我没有弄错我在做错,我在使用
hibernate
来获取和java.util.date
来存储上面使用的值
The process how data was stored and retrived: 数据存储和检索过程:
I stored value in mysql through hibernate: 我通过休眠将值存储在mysql中:
TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC"));
user.setCreatedDateTime(new java.util.Date());
...
...
...
Now I am getting the value from DB as 04/09/2014 11:40:17
. 现在,我从DB获得的值为
04/09/2014 11:40:17
。 When I performed this insertion the actual time was 04/09/2014 05:10:17 PM
IST
. 当我执行此插入操作时,实际时间为
IST
04/09/2014 05:10:17 PM
。 So it clears that the time being stored in DB is UTC time. 因此,很明显,存储在DB中的时间是UTC时间。
Now I am retriving time and setting in map in key value pair as map.put("dateregistered",c.getCreatedDateTime());
现在,我正在检索时间并将键值对中的map设置为
map.put("dateregistered",c.getCreatedDateTime());
user.getCreatedDateTime()
and retrieving value using struts 2 tag as mentioned above 并使用如上所述的struts 2标签检索值
:
instead of .
:
代替.
as separator; 0
. 0
。 The right TimeZone for IST (Indian Standard Time) is UTC+05:30
, then GMT+05:30
; IST(印度标准时间)的正确时区是
UTC+05:30
,然后是GMT+05:30
;
<s:date name = "dateregistered"
format = "MM/dd/yyyy HH:mm:ss a"
timezone = "GMT+05:30" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.