DateTimeItem.setUse24HourTime(Boolean.FALSE) works as expected: The Picker shows only Hours 1-12 (not 13-23) and a selector for AM|PM.
However, the Picker selection displays in the TextItem box with 24-Hour format. E.g., I just picked "1:30 PM," why does TextItem show "13:30"? This is potentially confusing to the end user, and it doesn't match the formatting used elsewhere on the page (ListGridFields, etc).
The most intuitive thing (to me) would be to just have the TextItem content format follow the setting for setUse24HourTime().
Please advise, thanks.
SmartClient Version: v9.1p_2016-07-08/PowerEdition Deployment (built 2016-07-08)
However, the Picker selection displays in the TextItem box with 24-Hour format. E.g., I just picked "1:30 PM," why does TextItem show "13:30"? This is potentially confusing to the end user, and it doesn't match the formatting used elsewhere on the page (ListGridFields, etc).
The most intuitive thing (to me) would be to just have the TextItem content format follow the setting for setUse24HourTime().
Please advise, thanks.
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.DateTimeItem; public class DemoDateTimeItemFormat implements EntryPoint { @Override public void onModuleLoad() { // Goal is to have Picker populate TextBox w/ padded format // "07/21/2016 02:56 PM" final DateTimeItem dateTimeItem = new DateTimeItem() { { setTitle("DateTime"); setValidateOnChange(Boolean.TRUE); setUse24HourTime(Boolean.FALSE); // Shows AM/PM in Picker // Issue: Picker value returned to TextItem is 24-Hour format, // confusing // Things I tried: // 1) Close, but not quite: // Format is "7/21/2016, 3:15:00 PM" (not padded; don't want seconds) // But this format provokes validation error "Must be a date" // setDateFormatter(DateDisplayFormat.TOLOCALESTRING); // either // setDisplayFormat(DateDisplayFormat.TOLOCALESTRING); // neither // 2) // setUseTextField(Boolean.FALSE); // Suppresses Time Display // setShowPickerTimeItem(Boolean.TRUE); // Time is hidden once picked // 3) No effect // setTextFieldProperties(new TextItem() { // { // setDateFormatter(DateDisplayFormat.TOUSSHORTDATE); // setTimeFormatter(TimeDisplayFormat.TOSHORTPADDEDTIME); // } // }); } }; DynamicForm dynamicForm = new DynamicForm() { { setFields(dateTimeItem); } }; dynamicForm.draw(); } }
Comment