Пример #1
0
 /**
  * Ensures the precision.
  *
  * @param date
  * @see DateHelper#getCalendar()
  */
 public DateHolder(final Date date) {
   this.calendar = DateHelper.getCalendar();
   if (date != null) {
     calendar.setTime(date);
   }
   ensurePrecision();
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * Ensures the precision.
  *
  * @param milliSecond
  */
 public DateHolder setMilliSecond(final int milliSecond) {
   calendar.set(Calendar.MILLISECOND, milliSecond);
   ensurePrecision();
   return this;
 }
Пример #5
0
 /**
  * Ensures the precision.
  *
  * @param second
  */
 public DateHolder setSecond(final int second) {
   calendar.set(Calendar.SECOND, second);
   ensurePrecision();
   return this;
 }
Пример #6
0
 /**
  * Ensures the precision.
  *
  * @param minute
  */
 public DateHolder setMinute(final int minute) {
   calendar.set(Calendar.MINUTE, minute);
   ensurePrecision();
   return this;
 }
Пример #7
0
 /**
  * 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;
 }
Пример #8
0
 /**
  * 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;
 }
Пример #9
0
 /** Clones the calendar. */
 public DateHolder setCalendar(final Calendar cal) {
   this.calendar = (Calendar) cal.clone();
   ensurePrecision();
   return this;
 }
Пример #10
0
 /**
  * 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();
 }