@SuppressWarnings("deprecation") public Date parse(DateBox dateBox, String dateText, boolean reportError) { Date date = null; try { if (dateText.length() > 0) { date = dateTimeFormat.parse(dateText); } } catch (IllegalArgumentException exception) { try { date = new Date(dateText); // We have parsed the text at higher resolution so do a round trip to get rid of extra: date = dateTimeFormat.parse(dateTimeFormat.format(date)); } catch (IllegalArgumentException e) { if (reportError) { dateBox.addStyleName(DATE_BOX_FORMAT_ERROR); } return null; } } return date; }
private void setError(final DateBox box) { box.addStyleName("dateBoxFormatError"); } };
@SuppressWarnings("deprecation") public Date parse(DateBox dateBox, String dateText, boolean reportError) { Date date = null; try { if (dateText.length() > 0) { date = dateTimeFormat.parse(dateText); } } catch (IllegalArgumentException exception) { try { date = new Date(dateText); // We have parsed the text at higher resolution so do a round trip to get rid of extra: date = dateTimeFormat.parse(dateTimeFormat.format(date)); } catch (IllegalArgumentException e) { if (reportError) { dateBox.addStyleName(DATE_BOX_FORMAT_ERROR); } return null; } } return date; }
@SuppressWarnings("deprecation") public Date parse(DateBox dateBox, String dateText, boolean reportError) { Date date = null; try { if (dateText.length() > 0) { date = dateTimeFormat.parse(dateText); } } catch (IllegalArgumentException exception) { try { date = new Date(dateText); // We have parsed the text at higher resolution so do a round trip to get rid of extra: date = dateTimeFormat.parse(dateTimeFormat.format(date)); } catch (IllegalArgumentException e) { if (reportError) { dateBox.addStyleName(DATE_BOX_FORMAT_ERROR); } return null; } } return date; }
public Widget createFilterWidget() { DatePicker datePicker = new DatePicker(); primaryDateBox = new DateBox(); primaryDateBox.setFormat(new DateBox.DefaultFormat(dateTimeFormat)); primaryDateBox.setWidth("100%"); primaryDateBox.addStyleName("dateBox"); primaryDateBox.addValueChangeHandler(valueChangeHandler); secondaryDateBox = new DateBox(); secondaryDateBox.setFormat(new DateBox.DefaultFormat(dateTimeFormat)); secondaryDateBox.setWidth("100%"); secondaryDateBox.addStyleName("dateBox"); secondaryDateBox.addValueChangeHandler(valueChangeHandler); operatorButton = new PushButton(); setButtonText(operatorButton, operator); operatorButton.addClickHandler(clickHandler); operatorButton.addStyleName("operatorButton"); horizontalPanel.addStyleName("columnDateFilter"); horizontalPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); horizontalPanel.add(operatorButton); horizontalPanel.add(primaryDateBox); horizontalPanel.add(secondaryDateBox); horizontalPanel.setCellWidth(operatorButton, "30px"); horizontalPanel.setCellWidth(primaryDateBox, "100%"); secondaryDateBox.setVisible(false); return horizontalPanel; }