/** * Returns the month. * * @return The month. */ public int getMonth() { return this.serialDate.getMonth(); }
/** * Returns the button color according to the specified date. * * @param targetDate the target date. * * @return the button color. */ protected Color getButtonColor(final SerialDate targetDate) { if (this.date.equals(this.date)) { return this.dateButtonColor; } else if (targetDate.getMonth() == this.date.getMonth()) { return this.monthButtonColor; } else { return this.chosenOtherButtonColor; } }
/** * Returns the button color according to the specified date. * * @param targetDate the target date. * * @return the button color. */ protected Color getButtonColor(final SerialDate targetDate) { if (this.date.equals(this.date)) { return this.dateButtonColor; } else if (targetDate.getMonth() == this.date.getMonth()) { return this.monthButtonColor; } else { return this.chosenOtherButtonColor; } }
/** * Returns the button color according to the specified date. * * @param targetDate the target date. * * @return the button color. */ protected Color getButtonColor(final SerialDate targetDate) { if (this.date.equals(this.date)) { return this.dateButtonColor; } else if (targetDate.getMonth() == this.date.getMonth()) { return this.monthButtonColor; } else { return this.chosenOtherButtonColor; } }
/** * Sets the date chosen in the panel. * * @param date the new date. */ public void setDate(final SerialDate date) { this.date = date; this.monthSelector.setSelectedIndex(date.getMonth() - 1); refreshYearSelector(); refreshButtons(); }
/** * Sets the date chosen in the panel. * * @param date the new date. */ public void setDate(final SerialDate date) { this.date = date; this.monthSelector.setSelectedIndex(date.getMonth() - 1); refreshYearSelector(); refreshButtons(); }
/** * Sets the date chosen in the panel. * * @param date the new date. */ public void setDate(final SerialDate date) { this.date = date; this.monthSelector.setSelectedIndex(date.getMonth() - 1); refreshYearSelector(); refreshButtons(); }
/** * Returns the last millisecond of the day, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar calendar to use (<code>null</code> not permitted). * * @return The end of the day as milliseconds since 01-01-1970. * * @throws NullPointerException if <code>calendar</code> is * <code>null</code>. */ public long getLastMillisecond(Calendar calendar) { int year = this.serialDate.getYYYY(); int month = this.serialDate.getMonth(); int day = this.serialDate.getDayOfMonth(); calendar.clear(); calendar.set(year, month - 1, day, 23, 59, 59); calendar.set(Calendar.MILLISECOND, 999); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); }
/** * Rolls the date forward to the last day of the month. * * @param base the base date. * * @return a new serial date. */ public SerialDate getEndOfCurrentMonth(final SerialDate base) { final int last = SerialDate.lastDayOfMonth( base.getMonth(), base.getYYYY() ); return SerialDate.createInstance(last, base.getMonth(), base.getYYYY()); }
/** * Rolls the date forward to the last day of the month. * * @param base the base date. * * @return a new serial date. */ public SerialDate getEndOfCurrentMonth(final SerialDate base) { final int last = SerialDate.lastDayOfMonth( base.getMonth(), base.getYYYY() ); return SerialDate.createInstance(last, base.getMonth(), base.getYYYY()); }
/** * Rolls the date forward to the last day of the month. * * @param base the base date. * * @return a new serial date. */ public SerialDate getEndOfCurrentMonth(final SerialDate base) { final int last = SerialDate.lastDayOfMonth( base.getMonth(), base.getYYYY() ); return SerialDate.createInstance(last, base.getMonth(), base.getYYYY()); }
/** * Converts the date to a string. * * @return a string representation of the date. */ public String toString() { return getDayOfMonth() + "-" + SerialDate.monthCodeToString(getMonth()) + "-" + getYYYY(); }
/** * Converts the date to a string. * * @return a string representation of the date. */ public String toString() { return getDayOfMonth() + "-" + SerialDate.monthCodeToString(getMonth()) + "-" + getYYYY(); }
/** * Converts the date to a string. * * @return a string representation of the date. */ public String toString() { return getDayOfMonth() + "-" + SerialDate.monthCodeToString(getMonth()) + "-" + getYYYY(); }
/** * Creates a new date by adding the specified number of years to the base * date. * * @param years the number of years to add (can be negative). * @param base the base date. * * @return A new date. */ public static SerialDate addYears(final int years, final SerialDate base) { final int baseY = base.getYYYY(); final int baseM = base.getMonth(); final int baseD = base.getDayOfMonth(); final int targetY = baseY + years; final int targetD = Math.min( baseD, SerialDate.lastDayOfMonth(baseM, targetY) ); return SerialDate.createInstance(targetD, baseM, targetY); }
/** * Creates a new date by adding the specified number of years to the base * date. * * @param years the number of years to add (can be negative). * @param base the base date. * * @return A new date. */ public static SerialDate addYears(final int years, final SerialDate base) { final int baseY = base.getYYYY(); final int baseM = base.getMonth(); final int baseD = base.getDayOfMonth(); final int targetY = baseY + years; final int targetD = Math.min( baseD, SerialDate.lastDayOfMonth(baseM, targetY) ); return SerialDate.createInstance(targetD, baseM, targetY); }
/** * Creates a new date by adding the specified number of years to the base * date. * * @param years the number of years to add (can be negative). * @param base the base date. * * @return A new date. */ public static SerialDate addYears(final int years, final SerialDate base) { final int baseY = base.getYYYY(); final int baseM = base.getMonth(); final int baseD = base.getDayOfMonth(); final int targetY = baseY + years; final int targetD = Math.min( baseD, SerialDate.lastDayOfMonth(baseM, targetY) ); return SerialDate.createInstance(targetD, baseM, targetY); }
/** * Returns the first date that is visible in the grid. This should always be in the month * preceding the month of the selected date. * * @return the first visible date. */ protected SerialDate getFirstVisibleDate() { SerialDate result = SerialDate.createInstance(1, this.date.getMonth(), this.date.getYYYY()); result = SerialDate.addDays(-1, result); while (result.getDayOfWeek() != getFirstDayOfWeek()) { result = SerialDate.addDays(-1, result); } return result; }
/** * Returns the first date that is visible in the grid. This should always be in the month * preceding the month of the selected date. * * @return the first visible date. */ protected SerialDate getFirstVisibleDate() { SerialDate result = SerialDate.createInstance(1, this.date.getMonth(), this.date.getYYYY()); result = SerialDate.addDays(-1, result); while (result.getDayOfWeek() != getFirstDayOfWeek()) { result = SerialDate.addDays(-1, result); } return result; }
/** * Returns the first date that is visible in the grid. This should always be in the month * preceding the month of the selected date. * * @return the first visible date. */ protected SerialDate getFirstVisibleDate() { SerialDate result = SerialDate.createInstance(1, this.date.getMonth(), this.date.getYYYY()); result = SerialDate.addDays(-1, result); while (result.getDayOfWeek() != getFirstDayOfWeek()) { result = SerialDate.addDays(-1, result); } return result; }