/** * Ensures the precision. * * @param date * @see DateHelper#getCalendar() */ public DateHolder(final Date date) { this.calendar = DateHelper.getCalendar(); if (date != null) { calendar.setTime(date); } ensurePrecision(); }
/** * Date will be set. Dependent on precision, also seconds etc. will be set to zero. Ensures the * precision. */ public DateHolder setDate(final Date date) { if (date == null) { return this; } this.calendar.setTime(date); ensurePrecision(); return this; }
/** * Sets the date by giving all datefields and compute all fields. * * @param year * @param month * @param day * @param hour * @param minute * @param second * @param millisecond * @see #computeTime() * @see #ensurePrecision() */ public DateHolder setDate( final int year, final int month, final int date, final int hourOfDay, final int minute, final int second, final int millisecond) { calendar.set(year, month, date, hourOfDay, minute, second); calendar.set(Calendar.MILLISECOND, millisecond); computeTime(); ensurePrecision(); return this; }
/** * Ensures the precision. * * @param milliSecond */ public DateHolder setMilliSecond(final int milliSecond) { calendar.set(Calendar.MILLISECOND, milliSecond); ensurePrecision(); return this; }
/** * Ensures the precision. * * @param second */ public DateHolder setSecond(final int second) { calendar.set(Calendar.SECOND, second); ensurePrecision(); return this; }
/** * Ensures the precision. * * @param minute */ public DateHolder setMinute(final int minute) { calendar.set(Calendar.MINUTE, minute); ensurePrecision(); return this; }
/** * Sets the precision of the date represented by this object. Ensures the precision. * * @param precision SECOND, MINUTE, MINUTE_15, HOUR_OF_DAY or DAY. */ public DateHolder setPrecision(final DatePrecision precision) { this.precision = precision; ensurePrecision(); return this; }
/** * Date will be set. Dependent on precision, also seconds etc. will be set to zero. Ensures the * precision. * * @param millis UTC millis */ public DateHolder setDate(final long millis) { this.calendar.setTimeInMillis(millis); ensurePrecision(); return this; }
/** Clones the calendar. */ public DateHolder setCalendar(final Calendar cal) { this.calendar = (Calendar) cal.clone(); ensurePrecision(); return this; }
/** * Ensures the precision. * * @param date * @param locale * @see DateHelper#getCalendar(Locale) */ public DateHolder(final Date date, final Locale locale) { this.calendar = DateHelper.getCalendar(locale); calendar.setTime(date); ensurePrecision(); }