struts2日期无法通过jquery datetimepicker获取时间 [英] struts2 date can not get time by jquery datetimepicker

查看:122
本文介绍了struts2日期无法通过jquery datetimepicker获取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在struts2中新建一个小型Web应用程序,我想要一个帖子是定时器,我选择jquery datetimpicker,用户选择时间和日期后,将会抹杀用户选择的时间和日期。

Im new in struts2 , and created a small web application, i want to a post is timer and i choose jquery datetimpicker, after user choose time and date ,it will dislay in time and date that user chosen.

我使用这个jquery

i use this jquery

http://www.javascriptkit.com/script/script2/tengcalendar.shtml

我的问题是,在struts2的操作可以获取日期,但是返回的时间是00:00:00

my problem is, in action of struts2 it can get date but time it return is 00:00:00

的结果是:

Tue Nov 20 00:00:00 ICT 2012

我的动作类是:

public class Foo extends ActionSupport{
    private Date fooDate;

     //getter - setter;
}

,我的表单是:

//form ....
<s:textfield name="fooDate" id="dateReleased" 
             cssClass="mws-textinput"  cssStyle="width:80%" />
<a href="javascript:NewCal('dateReleased','ddmmyyyy',true,12)">
      <img src="js/cal.gif" width="16" height="16" 
           border="0" alt="Pick a date">   
</a>

当我选择2012-11-20 5:40:10 PM

when i choose 2012-11-20 5:40:10PM

,在行动类中我刚刚获得

and in action class i just got

Tue Nov 20 00:00:00 ICT 2012

但是我想要

Tue Nov 20 5:40:10 PM ICT 2012

我该怎么办?

推荐答案

默认情况下,Struts2使用与当前请求关联的区域设置的短格式来解析日期。使用 String 为您 fooDate ,并转换为您需要的方法中的日期或创建类型转换器日期 http://struts.apache .org / 2.x / docs / type-conversion.html

By default Struts2 uses "short format for the Locale associated with the current request" to parse dates. Use String for you fooDate and convert to date in methods where you need it or create type converter for Date http://struts.apache.org/2.x/docs/type-conversion.html.

这篇关于struts2日期无法通过jquery datetimepicker获取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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