Class DatePicker

java.lang.Object
All Implemented Interfaces:
IsEditor<LeafValueEditor<Date>>, HasAttachHandlers, HasHighlightHandlers<Date>, HasShowRangeHandlers<Date>, HasValueChangeHandlers<Date>, HasHandlers, EventListener, TakesValue<Date>, HasValue<Date>, HasVisibility, IsRenderable, IsWidget

Standard GWT date picker.

CSS Style Rules

  • .gwt-DatePicker { }
  • .datePickerMonthSelector { the month selector widget }
  • .datePickerMonth { the month in the month selector widget }
  • .datePickerYear { the year in the month selector widget }
  • .datePickerPreviousButton { the previous month button }
  • .datePickerNextButton { the next month button }
  • .datePickerPreviousYearButton { the previous year button }
  • .datePickerNextYearButton { the next year button }
  • .datePickerDays { the portion of the picker that shows the days }
  • .datePickerWeekdayLabel { the label over weekdays }
  • .datePickerWeekendLabel { the label over weekends }
  • .datePickerDay { a single day }
  • .datePickerDayIsToday { today's date }
  • .datePickerDayIsWeekend { a weekend day }
  • .datePickerDayIsFiller { a day in another month }
  • .datePickerDayIsValue { the selected day }
  • .datePickerDayIsDisabled { a disabled day }
  • .datePickerDayIsHighlighted { the currently highlighted day }
  • .datePickerDayIsValueAndHighlighted { the highlighted day if it is also selected }

Example

public class DatePickerExample implements EntryPoint {

  public void onModuleLoad() {
    // Create a date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
      public void onValueChange(ValueChangeEvent<Date> event) {
        Date date = event.getValue();
        String dateString = DateTimeFormat.getMediumDateFormat().format(date);
        text.setText(dateString);
      }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);
    
    // Add the widgets to the page
    RootPanel.get().add(text);
    RootPanel.get().add(datePicker);
  }
}