コード例 #1
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the time from fields. The date part of this object will be unaffected.
  *
  * @param hour the hour
  * @param minuteOfHour the minute of the hour
  * @param secondOfMinute the second of the minute
  * @param millisOfSecond the millisecond of the second
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setTime(
     final int hour, final int minuteOfHour, final int secondOfMinute, final int millisOfSecond) {
   long instant =
       getChronology()
           .getDateTimeMillis(getMillis(), hour, minuteOfHour, secondOfMinute, millisOfSecond);
   setMillis(instant);
 }
コード例 #2
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Sets the status of rounding to use the specified field and mode. A null field or mode of
  * ROUND_NONE will disable rounding. Once set, the instant is then rounded using the new field and
  * mode.
  *
  * <p>Enabling rounding will cause all subsequent calls to {@link #setMillis(long)} to be rounded.
  * This can be used to control the precision of the instant, for example by setting a rounding
  * field of minuteOfDay, the seconds and milliseconds will always be zero.
  *
  * @param field rounding field or null to disable
  * @param mode rounding mode or ROUND_NONE to disable
  * @throws IllegalArgumentException if mode is unknown, no exception if field is null
  */
 public void setRounding(DateTimeField field, int mode) {
   if (field != null && (mode < ROUND_NONE || mode > ROUND_HALF_EVEN)) {
     throw new IllegalArgumentException("Illegal rounding mode: " + mode);
   }
   iRoundingField = (mode == ROUND_NONE ? null : field);
   iRoundingMode = (field == null ? ROUND_NONE : mode);
   setMillis(getMillis());
 }
コード例 #3
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
  /**
   * Sets the time zone of the datetime, changing the chronology and millisecond.
   *
   * <p>Changing the zone using this method retains the field values. The millisecond instant is
   * adjusted in the new zone to compensate.
   *
   * <p>If the chronology already has this time zone, no change occurs.
   *
   * @param newZone the time zone to use, null means default zone
   * @see #setZone
   */
  public void setZoneRetainFields(DateTimeZone newZone) {
    newZone = DateTimeUtils.getZone(newZone);
    DateTimeZone originalZone = DateTimeUtils.getZone(getZone());
    if (newZone == originalZone) {
      return;
    }

    long millis = originalZone.getMillisKeepLocal(newZone, getMillis());
    setChronology(getChronology().withZone(newZone)); // set via this class not super
    setMillis(millis);
  }
コード例 #4
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the date and time from fields.
  *
  * @param year the year
  * @param monthOfYear the month of the year
  * @param dayOfMonth the day of the month
  * @param hourOfDay the hour of the day
  * @param minuteOfHour the minute of the hour
  * @param secondOfMinute the second of the minute
  * @param millisOfSecond the millisecond of the second
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setDateTime(
     final int year,
     final int monthOfYear,
     final int dayOfMonth,
     final int hourOfDay,
     final int minuteOfHour,
     final int secondOfMinute,
     final int millisOfSecond) {
   long instant =
       getChronology()
           .getDateTimeMillis(
               year,
               monthOfYear,
               dayOfMonth,
               hourOfDay,
               minuteOfHour,
               secondOfMinute,
               millisOfSecond);
   setMillis(instant);
 }
コード例 #5
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the minute of the hour to the specified value.
  *
  * @param minuteOfHour the minute of hour
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setMinuteOfHour(final int minuteOfHour) {
   setMillis(getChronology().minuteOfHour().set(getMillis(), minuteOfHour));
 }
コード例 #6
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Sets the value of one of the fields of the instant, such as hourOfDay.
  *
  * @param type a field type, usually obtained from DateTimeFieldType, not null
  * @param value the value to set the field to
  * @throws IllegalArgumentException if the value is null or invalid
  */
 public void set(DateTimeFieldType type, int value) {
   if (type == null) {
     throw new IllegalArgumentException("Field must not be null");
   }
   setMillis(type.getField(getChronology()).set(getMillis(), value));
 }
コード例 #7
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of hours to the date.
  *
  * @param hours the hours to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addHours(final int hours) {
   setMillis(getChronology().hours().add(getMillis(), hours));
 }
コード例 #8
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the date from milliseconds. The time part of this object will be unaffected.
  *
  * @param instant an instant to copy the date from, time part ignored
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setDate(final long instant) {
   setMillis(getChronology().millisOfDay().set(instant, getMillisOfDay()));
 }
コード例 #9
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add an amount of time to the datetime.
  *
  * @param duration the millis to add
  * @throws ArithmeticException if the result exceeds the capacity of the instant
  */
 public void add(long duration) {
   setMillis(FieldUtils.safeAdd(getMillis(), duration)); // set via this class not super
 }
コード例 #10
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of seconds to the date.
  *
  * @param seconds the seconds to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addSeconds(final int seconds) {
   setMillis(getChronology().seconds().add(getMillis(), seconds));
 }
コード例 #11
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the millis of the second to the specified value.
  *
  * @param millisOfSecond the millis of second
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setMillisOfSecond(final int millisOfSecond) {
   setMillis(getChronology().millisOfSecond().set(getMillis(), millisOfSecond));
 }
コード例 #12
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the week of weekyear to the specified value.
  *
  * @param weekOfWeekyear the week of the weekyear
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setWeekOfWeekyear(final int weekOfWeekyear) {
   setMillis(getChronology().weekOfWeekyear().set(getMillis(), weekOfWeekyear));
 }
コード例 #13
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of weeks to the date.
  *
  * @param weeks the weeks to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addWeeks(final int weeks) {
   setMillis(getChronology().weeks().add(getMillis(), weeks));
 }
コード例 #14
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the month of the year to the specified value.
  *
  * @param monthOfYear the month of the year
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setMonthOfYear(final int monthOfYear) {
   setMillis(getChronology().monthOfYear().set(getMillis(), monthOfYear));
 }
コード例 #15
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of months to the date.
  *
  * @param months the months to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addMonths(final int months) {
   setMillis(getChronology().months().add(getMillis(), months));
 }
コード例 #16
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of years to the date.
  *
  * @param years the years to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addYears(final int years) {
   setMillis(getChronology().years().add(getMillis(), years));
 }
コード例 #17
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the year to the specified value.
  *
  * @param year the year
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setYear(final int year) {
   setMillis(getChronology().year().set(getMillis(), year));
 }
コード例 #18
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Adds to the instant specifying the duration and multiple to add.
  *
  * @param type a field type, usually obtained from DateTimeFieldType, not null
  * @param amount the amount to add of this duration
  * @throws IllegalArgumentException if the value is null or invalid
  * @throws ArithmeticException if the result exceeds the capacity of the instant
  */
 public void add(DurationFieldType type, int amount) {
   if (type == null) {
     throw new IllegalArgumentException("Field must not be null");
   }
   setMillis(type.getField(getChronology()).add(getMillis(), amount));
 }
コード例 #19
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the second of the day to the specified value.
  *
  * @param secondOfDay the second of day
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setSecondOfDay(final int secondOfDay) {
   setMillis(getChronology().secondOfDay().set(getMillis(), secondOfDay));
 }
コード例 #20
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the day of year to the specified value.
  *
  * @param dayOfYear the day of the year
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setDayOfYear(final int dayOfYear) {
   setMillis(getChronology().dayOfYear().set(getMillis(), dayOfYear));
 }
コード例 #21
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the second of the minute to the specified value.
  *
  * @param secondOfMinute the second of minute
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setSecondOfMinute(final int secondOfMinute) {
   setMillis(getChronology().secondOfMinute().set(getMillis(), secondOfMinute));
 }
コード例 #22
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the day of the month to the specified value.
  *
  * @param dayOfMonth the day of the month
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setDayOfMonth(final int dayOfMonth) {
   setMillis(getChronology().dayOfMonth().set(getMillis(), dayOfMonth));
 }
コード例 #23
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the millis of the day to the specified value.
  *
  * @param millisOfDay the millis of day
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setMillisOfDay(final int millisOfDay) {
   setMillis(getChronology().millisOfDay().set(getMillis(), millisOfDay));
 }
コード例 #24
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Sets the millisecond instant of this instant from another.
  *
  * <p>This method does not change the chronology of this instant, just the millisecond instant.
  *
  * @param instant the instant to use, null means now
  */
 public void setMillis(ReadableInstant instant) {
   long instantMillis = DateTimeUtils.getInstantMillis(instant);
   setMillis(instantMillis); // set via this class not super
 }
コード例 #25
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of milliseconds to the date. The implementation of this method differs from the
  * {@link #add(long)} method in that a DateTimeField performs the addition.
  *
  * @param millis the milliseconds to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addMillis(final int millis) {
   setMillis(getChronology().millis().add(getMillis(), millis));
 }
コード例 #26
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Add a number of days to the date.
  *
  * @param days the days to add
  * @throws IllegalArgumentException if the value is invalid
  */
 public void addDays(final int days) {
   setMillis(getChronology().days().add(getMillis(), days));
 }
コード例 #27
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the time from milliseconds. The date part of this object will be unaffected.
  *
  * @param millis an instant to copy the time from, date part ignored
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setTime(final long millis) {
   int millisOfDay = ISOChronology.getInstanceUTC().millisOfDay().get(millis);
   setMillis(getChronology().millisOfDay().set(getMillis(), millisOfDay));
 }
コード例 #28
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the hour of the day to the specified value.
  *
  * @param hourOfDay the hour of day
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setHourOfDay(final int hourOfDay) {
   setMillis(getChronology().hourOfDay().set(getMillis(), hourOfDay));
 }
コード例 #29
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Set the day of week to the specified value.
  *
  * @param dayOfWeek the day of the week
  * @throws IllegalArgumentException if the value is invalid
  */
 public void setDayOfWeek(final int dayOfWeek) {
   setMillis(getChronology().dayOfWeek().set(getMillis(), dayOfWeek));
 }
コード例 #30
0
ファイル: MutableDateTime.java プロジェクト: tbaum/gwt-time
 /**
  * Adds a period to this instant specifying how many times to add.
  *
  * <p>This will typically change the value of most fields.
  *
  * @param period the period to add, null means add zero
  * @param scalar direction and amount to add, which may be negative
  * @throws ArithmeticException if the result exceeds the capacity of the instant
  */
 public void add(ReadablePeriod period, int scalar) {
   if (period != null) {
     setMillis(getChronology().add(period, getMillis(), scalar)); // set via this class not super
   }
 }