dateField.setResolution(Resolution.SECOND);
ArrayList<String> timeZoneCodes = new ArrayList<String>();
timeZoneCodes.add(nullValue);
timeZoneCodes.addAll(Arrays.asList(TimeZone.getAvailableIDs()));
ComboBox timezoneSelector = new ComboBox("Select time zone",
timeZoneCodes) {
@Override
public String getItemCaption(Object itemId) {
if (itemId == nullValue || itemId == null) {
TimeZone timeZone = TimeZone.getDefault();
return "Default time zone (" + timeZone.getDisplayName()
+ ")";
} else {
TimeZone timeZone = TimeZone.getTimeZone((String) itemId);
return itemId + " (" + timeZone.getDisplayName() + ")";
}
}
};
timezoneSelector.setValue("UTC");
timezoneSelector.setImmediate(true);
timezoneSelector.setNullSelectionAllowed(true);
timezoneSelector.setNullSelectionItemId(nullValue);
timezoneSelector.setFilteringMode(FilteringMode.CONTAINS);
timezoneSelector.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
Object value = event.getProperty().getValue();
TimeZone timeZone;
if (value == nullValue || value == null) {