Example #1
0
 protected BasePeriod(ReadablePeriod period, Chronology chrono) {
   super();
   iType = checkPeriodType(period.getPeriodType());
   if (this instanceof ReadWritablePeriod) {
     ((ReadWritablePeriod) this).setPeriod(period);
   }
   iValues = period.toMutablePeriod().getValues();
 }
Example #2
0
 protected BasePeriod(ReadablePeriod period, PeriodType type, Chronology chrono) {
   super();
   iType = checkPeriodType(type);
   if (this instanceof ReadWritablePeriod) {
     ((ReadWritablePeriod) this).setPeriod(period);
   } else
     iValues =
         new MutablePeriod(period, type, chrono)
             .getValues(); // -sf- using period.toMutablePeriod() will cause
   // infinite recursion. Thus, use constructor directly
 }
Example #3
0
 private void setValues(Object duration, PeriodType type, Chronology chrono) {
   type = checkPeriodType(type);
   iType = type;
   if (this instanceof ReadWritablePeriod) {
     chrono = DateTimeUtils.getChronology(chrono);
     long dur;
     if (duration instanceof ReadableDuration) {
       dur = ((ReadableDuration) duration).getMillis();
     } else if (duration instanceof ReadableInterval) {
       dur = ((ReadableInterval) duration).toDurationMillis();
     } else dur = 0L;
     iValues = chrono.get((ReadWritablePeriod) this, dur);
     for (int i = 0; i < iValues.length; i++) ((ReadWritablePeriod) this).setValue(i, iValues[i]);
   } else {
     if (duration instanceof ReadableDuration)
       iValues = new MutablePeriod((ReadableDuration) duration, type, chrono).getValues();
     else iValues = new MutablePeriod((ReadableInterval) duration, type, chrono).getValues();
   }
 }