/** * Creates a new hour. * * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Hour(int hour, int day, int month, int year) { this(hour, new Day(day, month, year)); }
/** * Tests the equality of this object against an arbitrary Object. * <P> * This method will return true ONLY if the object is an Hour object * representing the same hour as this instance. * * @param obj the object to compare (<code>null</code> permitted). * * @return <code>true</code> if the hour and day value of the object * is the same as this. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Hour)) { return false; } Hour that = (Hour) obj; if (this.hour != that.hour) { return false; } if (!this.day.equals(that.day)) { return false; } return true; }
/** * Returns the second. * * @return The second. */ public Second getSecond() { return new Second(this.second, this.minute, this.hour, this.day.getDayOfMonth(), this.day.getMonth(), this.day.getYear()); }
/** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar ({@code null} not permitted). * * @since 1.0.3 */ @Override public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); }
/** * Returns the day-of-the-month in which this hour falls. * * @return The day-of-the-month. */ public int getDayOfMonth() { return this.day.getDayOfMonth(); }
result = getDay().compareTo(h.getDay()); if (result == 0) { result = this.hour - h.getHour();
/** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (<code>null</code> not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); }
/** * Returns the day-of-the-month in which this hour falls. * * @return The day-of-the-month. */ public int getDayOfMonth() { return this.day.getDayOfMonth(); }
result = getDay().compareTo(h.getDay()); if (result == 0) { result = this.hour - h.getHour();
/** * Returns the second. * * @return The second. */ public Second getSecond() { return new Second(this.second, this.minute, this.hour, this.day.getDayOfMonth(), this.day.getMonth(), this.day.getYear()); }
/** * Tests the equality of this object against an arbitrary Object. * <P> * This method will return true ONLY if the object is an Hour object * representing the same hour as this instance. * * @param obj the object to compare ({@code null} permitted). * * @return {@code true} if the hour and day value of the object * is the same as this. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Hour)) { return false; } Hour that = (Hour) obj; if (this.hour != that.hour) { return false; } if (!this.day.equals(that.day)) { return false; } return true; }
/** * Returns the last millisecond of the hour. * * @param calendar the calendar/timezone ({@code null} not permitted). * * @return The last millisecond. * * @throws NullPointerException if {@code calendar} is * {@code null}. */ @Override public long getLastMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int dom = this.day.getDayOfMonth(); calendar.set(year, month, dom, this.hour, 59, 59); calendar.set(Calendar.MILLISECOND, 999); return calendar.getTimeInMillis(); }
return false; if (!this.day.equals(that.day)) { return false;
/** * Creates a new hour. * * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Hour(int hour, int day, int month, int year) { this(hour, new Day(day, month, year)); }
/** * Returns the first millisecond of the hour. * * @param calendar the calendar/timezone ({@code null} not permitted). * * @return The first millisecond. * * @throws NullPointerException if {@code calendar} is * {@code null}. */ @Override public long getFirstMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int dom = this.day.getDayOfMonth(); calendar.set(year, month, dom, this.hour, 0, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); }
return false; if (!this.day.equals(that.day)) { return false;
/** * Creates a new minute. * * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Minute(int minute, int hour, int day, int month, int year) { this(minute, new Hour(hour, new Day(day, month, year))); }
/** * Returns the first millisecond of the minute. * * @param calendar the calendar/timezone ({@code null} not permitted). * * @return The first millisecond. * * @throws NullPointerException if {@code calendar} is {@code null}. */ @Override public long getFirstMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int d = this.day.getDayOfMonth(); calendar.clear(); calendar.set(year, month, d, this.hour, this.minute, this.second); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis(); }