New issue 692 by schweige...@gmail.com: Timepicker 24 Hour issue
http://code.google.com/p/struts2-jquery/issues/detail?id=692
I use the current struts2-jquery Version (3.1.1) with Struts 2.2.3.
Here is an example of my issue. If I use the timepicker additional to the
datepicker and the selected time from the database is a P.M. time, the hour
attribute in the option array is set to the A.M. value.
In my example I selected 20 o'clock (see value), but 8 o'clock is displayed.
<input type="text" name="corporateCustomerOffer.date" value="31.10.2011
20:00:00" disabled="disabled" id="corporateCustomerOfferDate"
style="width:478px"/></div> </div>
<script type='text/javascript'>
jQuery(document).ready(function () {
var options_corporateCustomerOfferDate = {};
options_corporateCustomerOfferDate.day = 31;
options_corporateCustomerOfferDate.month = 9;
options_corporateCustomerOfferDate.year = 2011;
options_corporateCustomerOfferDate.hour = 8;
options_corporateCustomerOfferDate.minute = 0;
options_corporateCustomerOfferDate.second = 0;
options_corporateCustomerOfferDate.showOn = "focus";
options_corporateCustomerOfferDate.buttonImage
= "/booking/struts/js/calendar.gif";
options_corporateCustomerOfferDate.duration = "fast";
options_corporateCustomerOfferDate.showAnim = "slideDown";
options_corporateCustomerOfferDate.displayformat = "dd.mm.yy";
options_corporateCustomerOfferDate.timepicker = true;
options_corporateCustomerOfferDate.jqueryaction = "datepicker";
options_corporateCustomerOfferDate.id = "corporateCustomerOfferDate";
options_corporateCustomerOfferDate.name = "corporateCustomerOffer.date";
jQuery.struts2_jquery.bind(jQuery('#corporateCustomerOfferDate'),options_corporateCustomerOfferDate);
});
</script>
Here is my struts tag:
<sj:datepicker id="corporateCustomerOfferDate"
key="corporateCustomerOffer.date" displayFormat="dd.mm.yy"
value="%{getText('fieldFormat.date',{corporateCustomerOffer.date.getTime()})}"
disabled="disabledValue" cssStyle="width:478px"
timepickerStepMinute="15"
showOn="focus" showAnim="slideDown" duration="fast" timepicker="true" />
I enabled the timepickerAmPm="true" option. It's like i said. If I select a
PM timestamp and save it to the database. Everything is fine. But if I load
a value from the database like '31.10.2011 20:00:00', the value is
automatically set to AM.
Found the bug:
DatePicker.java Line 419
addParameter("hourValue", "" + calendar.get(Calendar.HOUR));
should be
addParameter("hourValue", "" + calendar.get(Calendar.HOUR_OF_DAY));
After building the new version with the change above. Everything works fine!
Comment #5 on issue 692 by johgep: Timepicker 24 Hour issue
http://code.google.com/p/struts2-jquery/issues/detail?id=692
Thank you for investing time to find out the solution.
Comment #6 on issue 692 by johgep: Timepicker 24 Hour issue
http://code.google.com/p/struts2-jquery/issues/detail?id=692
http://code.google.com/p/struts2-jquery/source/detail?r=1549