/** * Sets the format used to control formatting and parsing of dates in this * {@link DateBox}. If this {@link DateBox} is not empty, the contents of date * box will be replaced with current contents in the new format. * * @param format the new date format */ public void setFormat(Format format) { assert format != null : "A Date box may not have a null format"; if (this.format != format) { Date date = getValue(); // This call lets the formatter do whatever other clean up is required to // switch formatters. // this.format.reset(this, true); // Now update the format and show the current date using the new format. this.format = format; setValue(date); } }
/** * Sets the format used to control formatting and parsing of dates in this * {@link DateBox}. If this {@link DateBox} is not empty, the contents of date * box will be replaced with current contents in the new format. * * @param format the new date format */ public void setFormat(Format format) { assert format != null : "A Date box may not have a null format"; if (this.format != format) { Date date = getValue(); // This call lets the formatter do whatever other clean up is required to // switch formatters. // this.format.reset(this, true); // Now update the format and show the current date using the new format. this.format = format; setValue(date); } }
private void validate() { String valueAsString = dateBox.getTextBox().getValue(); if (Strings.isNullOrEmpty(valueAsString)) { valueUpdater.update(null); } else { Date dateValue = this.dateBox.getFormat().parse(dateBox, valueAsString, false); if(dateValue == null) { valueUpdater.onInvalid(I18N.MESSAGES.dateFieldInvalidValue(FORMAT)); } else { valueUpdater.update(new LocalDate(dateValue)); } } } }
private void setValue(Date oldDate, Date date, boolean fireEvents, boolean updateText) { if (date != null) { picker.setCurrentMonth(date); } picker.setValue(date, false); if (updateText) { format.reset(this, false); box.setText(getFormat().format(this, date)); } if (fireEvents) { DateChangeEvent.fireIfNotEqualDates(this, oldDate, date); } }
private void setValue(Date oldDate, Date date, boolean fireEvents, boolean updateText) { if (date != null) { picker.setCurrentMonth(date); } picker.setValue(date, false); if (updateText) { format.reset(this, false); box.setText(getFormat().format(this, date)); } if (fireEvents) { DateChangeEvent.fireIfNotEqualDates(this, oldDate, date); } }
/** * Sets the format used to control formatting and parsing of dates in this * {@link DateBox}. If this {@link DateBox} is not empty, the contents of date * box will be replaced with current contents in the new format. * * @param format the new date format */ public void setFormat(Format format) { assert format != null : "A Date box may not have a null format"; if (this.format != format) { Date date = getValue(); // This call lets the formatter do whatever other clean up is required to // switch formatters. // this.format.reset(this, true); // Now update the format and show the current date using the new format. this.format = format; setValue(date); } }
private void setValue(Date oldDate, Date date, boolean fireEvents, boolean updateText) { if (date != null) { picker.setCurrentMonth(date); } picker.setValue(date, false); if (updateText) { format.reset(this, false); box.setText(getFormat().format(this, date)); } if (fireEvents) { DateChangeEvent.fireIfNotEqualDates(this, oldDate, date); } }