【发布时间】:2015-09-27 14:40:32
【问题描述】:
我对日期格式有一个奇怪的问题。 就像,我正在使用设置为 dd/mm/yy 格式的 jquery 日期选择器。 所以,当我用 01/09/2015 填写该字段时,它应该意味着日期是 2015 年 9 月 1 日。 但是,我看到当我收到控制器中的日期作为日期时,实际日期看起来像 Fri Jan 09 00:00:00 IST 2015。这不是我想要的,我希望日期为 2015 年 9 月 1 日。请帮助我解决我所缺少的问题。 以下是代码 sn-p 供您参考- jsp
function() {
$(".datepicker").datepicker({
dateFormat: "dd/mm/yy",
maxDate : 0,
changeMonth : true,//this option for allowing user to select month
changeYear : true, //this option for allowing user to select from year range
showOn : "button",
buttonImage : "<c:url value="resources/images/calendar.gif"/>",
buttonImageOnly : true,
buttonText : "Select date",
showOtherMonths : true,
selectOtherMonths : true
})
});
<form:form method="post" id="inbound_form" modelAttribute="formObject" action="submit" onsubmit="return validateInboundAdd()" >
<form:input class="datepicker required" style="height:14px"
id="dateReceived" size="10" maxlength="10" type="text" readonly="readonly" value="${dateReceivedContinue}"
path="dateReceived" onfocus="inputFocus(this)" onblur="inputBlur(this)"/>
控制器
@RequestMapping(value = "/submit" , method = RequestMethod.POST , params="Save ")
public String submit(@ModelAttribute("formObject") modelObject modelObject,
System.out.println("received date -"+modelObject.getDate_received()); // This is giving me the mm/dd/yyyy output, which I want as dd/mm/yyyy. This is getter of the date field 'dateReceived'
【问题讨论】:
标签: java jquery date datepicker