struts2中的日期更改问题 [英] Date change issue in struts2
本文介绍了struts2中的日期更改问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我从日期选择器中选择日期格式时,它以dd / MM / yyyy格式显示。
将日期传递给java类成为MM / dd / yyyy。
由于这个原因,我无法通过12以上的日期,它显示输入错误。
When i selecting the date format from date picker it showing in "dd/MM/yyyy" format. Passing the date into java class it become "MM/dd/yyyy". Due to this reason i can't pass the day above 12 ,it showing input error.
示例:11/08/2014在jsp同一日期显示在
java类是星期六11月08 00:00:00 IST 2014
Example: 11/08/2014 in jsp the same date showing in
java class is Sat Nov 08 00:00:00 IST 2014
推荐答案
您可以使用DateFormat以所需的格式转换日期。
You can use DateFormat to convert the date in the desired format.
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
String currDate = dateFormat.format(cal.getTime());
这篇关于struts2中的日期更改问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文