Пример #1
0
 @Override
 public Time plus(Integer hour, Integer minute, Integer second, Integer nanoseconds) {
   DateTimeInterval interval = new DateTimeInterval(this);
   interval.plus(hour, minute, second, nanoseconds);
   return GregorianDateTime.newTime(
       interval.getResultHour(),
       interval.getResultMinute(),
       interval.getResultSecond(),
       interval.getResultNanoseconds());
 }
Пример #2
0
 @Override
 public Time minus(Time that) {
   DateTimeInterval interval = new DateTimeInterval(this);
   interval.minus(that.getHour(), that.getMinute(), that.getSecond(), that.getNanoseconds());
   return GregorianDateTime.newTime(
       interval.getResultHour(),
       interval.getResultMinute(),
       interval.getResultSecond(),
       interval.getResultNanoseconds());
 }
Пример #3
0
  @Override
  public Time changeTimeZone(TimeZone fromTimeZone, TimeZone toTimeZone) {
    Calendar fromDate = new GregorianCalendar(fromTimeZone);
    fromDate.set(Calendar.HOUR_OF_DAY, getHour());
    fromDate.set(Calendar.MINUTE, getMinute());
    // other items zeroed out here, since they don't matter for time zone calculations
    fromDate.set(Calendar.SECOND, 0);
    fromDate.set(Calendar.MILLISECOND, 0);

    // millisecond precision is OK here, since the seconds/nanoseconds are not part of the calc
    Calendar toDate = new GregorianCalendar(toTimeZone);
    toDate.setTimeInMillis(fromDate.getTimeInMillis());

    return GregorianDateTime.newTime(
        toDate.get(Calendar.HOUR_OF_DAY), getMinute(), getSecond(), getNanoseconds());
  }
Пример #4
0
 @Override
 public boolean isInThePast(TimeZone timeZone) {
   return GregorianDateTime.nowTimeOnly(timeZone).compareTo(this) > 0;
 }