/** * Creates a new <tt>CalendarDateSpinnerData</tt> bounded from * <tt>1900-01-01</tt> to <tt>2099-12-31</tt>. */ public CalendarDateSpinnerData() { this(new CalendarDate(1900, 0, 0), new CalendarDate(2099, 11, 30)); }
/** * Creates a new <tt>CalendarDateSpinnerData</tt> bounded from * <tt>1900-01-01</tt> to <tt>2099-12-31</tt>. */ public CalendarDateSpinnerData() { this(new CalendarDate(1900, 0, 0), new CalendarDate(2099, 11, 30)); }
public Calendar() { this(new CalendarDate()); }
public CalendarButton() { this(new CalendarDate()); }
public CalendarButton() { this(new CalendarDate()); }
public Calendar() { this(new CalendarDate()); }
/** * Gets the calendar date at the specified index. * * @param index * The index of the calendar date to retrieve. */ @Override public CalendarDate get(int index) { if (index < 0 || index >= length) { throw new IndexOutOfBoundsException("Index out of bounds: " + index); } // Move the calendar's fields to match the specified index calendar.add(Calendar.DAY_OF_YEAR, index - calendarIndex); calendarIndex = index; // Calculate the desired fields int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH) - 1; return new CalendarDate(year, month, day); }
/** * Gets the calendar date at the specified index. * * @param index * The index of the calendar date to retrieve. */ @Override public CalendarDate get(int index) { if (index < 0 || index >= length) { throw new IndexOutOfBoundsException("Index out of bounds: " + index); } // Move the calendar's fields to match the specified index calendar.add(Calendar.DAY_OF_YEAR, index - calendarIndex); calendarIndex = index; // Calculate the desired fields int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH) - 1; return new CalendarDate(year, month, day); }
/** * Creates a new date representing the specified date string. The date * string must be in the <tt>ISO 8601</tt> "calendar date" format, * which is <tt>[YYYY]-[MM]-[DD]</tt>. * * @param value * A string in the form of <tt>[YYYY]-[MM]-[DD]</tt> (e.g. 2008-07-23). */ public static CalendarDate decode(String value) { Matcher matcher = PATTERN.matcher(value); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid date format: " + value); } int year = Integer.parseInt(matcher.group(1)); int month = Integer.parseInt(matcher.group(2)) - 1; int day = Integer.parseInt(matcher.group(3)) - 1; return new CalendarDate(year, month, day); } }
/** * Creates a new date representing the specified date string. The date * string must be in the <tt>ISO 8601</tt> "calendar date" format, * which is <tt>[YYYY]-[MM]-[DD]</tt>. * * @param value * A string in the form of <tt>[YYYY]-[MM]-[DD]</tt> (e.g. 2008-07-23). */ public static CalendarDate decode(String value) { Matcher matcher = PATTERN.matcher(value); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid date format: " + value); } int year = Integer.parseInt(matcher.group(1)); int month = Integer.parseInt(matcher.group(2)) - 1; int day = Integer.parseInt(matcher.group(3)) - 1; return new CalendarDate(year, month, day); } }
/** * Adds the specified number of days to this calendar date and returns the * resulting calendar date. The number of days may be negative, in which * case the result will be a date before this calendar date. * <p> * More formally, it is defined that given calendar dates <tt>c1</tt> and * <tt>c2</tt>, the following will return <tt>true</tt>: * <pre> * c1.add(c2.subtract(c1)).equals(c2); * </pre> * * @param days * The number of days to add to (or subtract from if negative) this * calendar date. * * @return * The resulting calendar date. */ public CalendarDate add(int days) { GregorianCalendar calendar = toCalendar(); calendar.add(Calendar.DAY_OF_YEAR, days); return new CalendarDate(calendar); }
/** * Adds the specified number of days to this calendar date and returns the * resulting calendar date. The number of days may be negative, in which * case the result will be a date before this calendar date. * <p> * More formally, it is defined that given calendar dates <tt>c1</tt> and * <tt>c2</tt>, the following will return <tt>true</tt>: * <pre> * c1.add(c2.subtract(c1)).equals(c2); * </pre> * * @param days * The number of days to add to (or subtract from if negative) this * calendar date. * * @return * The resulting calendar date. */ public CalendarDate add(int days) { GregorianCalendar calendar = toCalendar(); calendar.add(Calendar.DAY_OF_YEAR, days); return new CalendarDate(calendar); }
public CalendarButton(int year, int month) { this.year = year; this.month = month; setDataRenderer(DEFAULT_DATA_RENDERER); installSkin(CalendarButton.class); setSelectedDate(new CalendarDate()); }
public CalendarButton(int year, int month) { this.year = year; this.month = month; setDataRenderer(DEFAULT_DATA_RENDERER); installSkin(CalendarButton.class); setSelectedDate(new CalendarDate()); }