/** * Sets the date by giving all datefields and compute all fields. Set millisecond to zero. * * @param year * @param month * @param date * @param hourOfDay * @param minute * @param second * @see #setDate(int, int, int, int, int, int, int) */ public DateHolder setDate( final int year, final int month, final int date, final int hourOfDay, final int minute, final int second) { setDate(year, month, date, hourOfDay, minute, second, 0); return this; }
private void calculate() { DateHolder dateHolder = new DateHolder(cal, DatePrecision.DAY); year = dateHolder.getYear(); month = dateHolder.getMonth(); dateHolder.setBeginOfMonth(); begin = dateHolder.getDate(); // Storing begin of month. dateHolder.setEndOfMonth(); end = dateHolder.getDate(); // Storing end of month. dateHolder.setDate(begin); // reset to begin of month dateHolder.computeTime(); dateHolder.setBeginOfWeek(); // get first week (with days of previous month) weeks = new ArrayList<WeekHolder>(); do { WeekHolder week = new WeekHolder(dateHolder.getCalendar(), month); weeks.add(week); dateHolder.add(Calendar.WEEK_OF_YEAR, 1); } while (dateHolder.getMonth() == month); }
/** * Sets second and millisecond to zero. * * @param year * @param month * @param day * @param hourOfDay * @param minute * @see #setDate(int, int, int, int, int, int, int) */ public DateHolder setDate( final int year, final int month, final int day, final int hourOfDay, final int minute) { setDate(year, month, day, hourOfDay, minute, 0, 0); return this; }
/** * Sets hour, minute, second and millisecond to zero. * * @param year * @param month * @param day * @see #setDate(int, int, int, int, int, int, int) */ public DateHolder setDate(final int year, final int month, final int day) { setDate(year, month, day, 0, 0, 0, 0); return this; }
/** * Stops calculation for more than 500 years. * * @param other * @return other.days - this.days. */ public int daysBetween(final Date other) { final DateHolder o = new DateHolder(calendar); o.setDate(other); return daysBetween(o); }
/** * Has the given date the same day? The given date will be converted into a calendar (clone from * this) with same time zone. * * @param date * @return */ public boolean isSameDay(final Date date) { final DateHolder other = new DateHolder(this.calendar); other.setDate(date); return isSameDay(other); }