/** * Returns the day of the month. * * @return The day of the month. */ public int getDayOfMonth() { return this.serialDate.getDayOfMonth(); }
/** * 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(); }
/** * Returns the first 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 start of the day as milliseconds since 01-01-1970. * * @throws NullPointerException if <code>calendar</code> is * <code>null</code>. */ public long getFirstMillisecond(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, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); }
/** * 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(); }
final JComboBox c = (JComboBox) e.getSource(); this.date = SerialDate.createInstance( this.date.getDayOfMonth(), c.getSelectedIndex() + 1, this.date.getYYYY() ); refreshButtons(); final Integer y = (Integer) c.getSelectedItem(); this.date = SerialDate.createInstance( this.date.getDayOfMonth(), this.date.getMonth(), y.intValue() ); refreshYearSelector();
final JComboBox c = (JComboBox) e.getSource(); this.date = SerialDate.createInstance( this.date.getDayOfMonth(), c.getSelectedIndex() + 1, this.date.getYYYY() ); refreshButtons(); final Integer y = (Integer) c.getSelectedItem(); this.date = SerialDate.createInstance( this.date.getDayOfMonth(), this.date.getMonth(), y.intValue() ); refreshYearSelector();
/** * 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 true if the specified date is the last day in February (that is, the * 28th in non-leap years, and the 29th in leap years). * * @param d the date to be tested. * * @return a boolean that indicates whether or not the specified date is * the last day of February. */ public static boolean isLastDayOfFebruary(final SerialDate d) { final int dom; if (d.getMonth() == MonthConstants.FEBRUARY) { dom = d.getDayOfMonth(); if (SerialDate.isLeapYear(d.getYYYY())) { return (dom == 29); } else { return (dom == 28); } } else { // not even February return false; } }
/** * Returns true if the specified date is the last day in February (that is, the * 28th in non-leap years, and the 29th in leap years). * * @param d the date to be tested. * * @return a boolean that indicates whether or not the specified date is * the last day of February. */ public static boolean isLastDayOfFebruary(final SerialDate d) { final int dom; if (d.getMonth() == MonthConstants.FEBRUARY) { dom = d.getDayOfMonth(); if (SerialDate.isLeapYear(d.getYYYY())) { return (dom == 29); } else { return (dom == 28); } } else { // not even February return false; } }
/** * Returns true if the specified date is the last day in February (that is, the * 28th in non-leap years, and the 29th in leap years). * * @param d the date to be tested. * * @return a boolean that indicates whether or not the specified date is * the last day of February. */ public static boolean isLastDayOfFebruary(final SerialDate d) { final int dom; if (d.getMonth() == MonthConstants.FEBRUARY) { dom = d.getDayOfMonth(); if (SerialDate.isLeapYear(d.getYYYY())) { return (dom == 29); } else { return (dom == 28); } } else { // not even February return false; } }
final int y2; if (start.isBefore(end)) { // check the order of the dates d1 = start.getDayOfMonth(); m1 = start.getMonth(); y1 = start.getYYYY(); d2 = end.getDayOfMonth(); m2 = end.getMonth(); y2 = end.getYYYY();
final int y2; if (start.isBefore(end)) { // check the order of the dates d1 = start.getDayOfMonth(); m1 = start.getMonth(); y1 = start.getYYYY(); d2 = end.getDayOfMonth(); m2 = end.getMonth(); y2 = end.getYYYY();
final int y2; if (start.isBefore(end)) { // check the order of the dates d1 = start.getDayOfMonth(); m1 = start.getMonth(); y1 = start.getYYYY(); d2 = end.getDayOfMonth(); m2 = end.getMonth(); y2 = end.getYYYY();
/** * Creates a new date by adding the specified number of months to the base * date. * <P> * If the base date is close to the end of the month, the day on the result * may be adjusted slightly: 31 May + 1 month = 30 June. * * @param months the number of months to add (can be negative). * @param base the base date. * * @return a new date. */ public static SerialDate addMonths(final int months, final SerialDate base) { final int yy = (12 * base.getYYYY() + base.getMonth() + months - 1) / 12; final int mm = (12 * base.getYYYY() + base.getMonth() + months - 1) % 12 + 1; final int dd = Math.min( base.getDayOfMonth(), SerialDate.lastDayOfMonth(mm, yy) ); return SerialDate.createInstance(dd, mm, yy); }
/** * Creates a new date by adding the specified number of months to the base * date. * <P> * If the base date is close to the end of the month, the day on the result * may be adjusted slightly: 31 May + 1 month = 30 June. * * @param months the number of months to add (can be negative). * @param base the base date. * * @return a new date. */ public static SerialDate addMonths(final int months, final SerialDate base) { final int yy = (12 * base.getYYYY() + base.getMonth() + months - 1) / 12; final int mm = (12 * base.getYYYY() + base.getMonth() + months - 1) % 12 + 1; final int dd = Math.min( base.getDayOfMonth(), SerialDate.lastDayOfMonth(mm, yy) ); return SerialDate.createInstance(dd, mm, yy); }
/** * Creates a new date by adding the specified number of months to the base * date. * <P> * If the base date is close to the end of the month, the day on the result * may be adjusted slightly: 31 May + 1 month = 30 June. * * @param months the number of months to add (can be negative). * @param base the base date. * * @return a new date. */ public static SerialDate addMonths(final int months, final SerialDate base) { final int yy = (12 * base.getYYYY() + base.getMonth() + months - 1) / 12; final int mm = (12 * base.getYYYY() + base.getMonth() + months - 1) % 12 + 1; final int dd = Math.min( base.getDayOfMonth(), SerialDate.lastDayOfMonth(mm, yy) ); return SerialDate.createInstance(dd, mm, yy); }