// Adapted from the package-private BasicDayOfMonthDateTimeField
 @Override
 public int getMaximumValue(ReadablePartial partial) {
   if (partial.isSupported(DateTimeFieldType.monthOfYear())) {
     int month = partial.get(DateTimeFieldType.monthOfYear());
     return this.daysInMonth[month - 1]; // Months are 1-based
   }
   return this.getMaximumValue();
 }
Beispiel #2
0
 /**
  * Creates a period from the given duration and end point.
  *
  * <p>The two partials must contain the same fields, thus you can specify two <code>LocalDate
  * </code> objects, or two <code>LocalTime</code> objects, but not one of each. As these are
  * Partial objects, time zones have no effect on the result.
  *
  * <p>The two partials must also both be contiguous - see {@link
  * DateTimeUtils#isContiguous(ReadablePartial)} for a definition. Both <code>LocalDate</code> and
  * <code>LocalTime</code> are contiguous.
  *
  * @param start the start of the period, must not be null
  * @param end the end of the period, must not be null
  * @param type which set of fields this period supports, null means standard
  * @throws IllegalArgumentException if the partials are null or invalid
  * @since 1.1
  */
 protected BasePeriod(ReadablePartial start, ReadablePartial end, PeriodType type) {
   super();
   if (start == null || end == null) {
     throw new IllegalArgumentException("ReadablePartial objects must not be null");
   }
   if (start instanceof BaseLocal
       && end instanceof BaseLocal
       && start.getClass() == end.getClass()) {
     // for performance
     type = checkPeriodType(type);
     long startMillis = ((BaseLocal) start).getLocalMillis();
     long endMillis = ((BaseLocal) end).getLocalMillis();
     Chronology chrono = start.getChronology();
     chrono = DateTimeUtils.getChronology(chrono);
     iType = type;
     iValues = chrono.get(this, startMillis, endMillis);
   } else {
     if (start.size() != end.size()) {
       throw new IllegalArgumentException(
           "ReadablePartial objects must have the same set of fields");
     }
     for (int i = 0, isize = start.size(); i < isize; i++) {
       if (start.getFieldType(i) != end.getFieldType(i)) {
         throw new IllegalArgumentException(
             "ReadablePartial objects must have the same set of fields");
       }
     }
     if (DateTimeUtils.isContiguous(start) == false) {
       throw new IllegalArgumentException("ReadablePartial objects must be contiguous");
     }
     iType = checkPeriodType(type);
     Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC();
     iValues = chrono.get(this, chrono.set(start, 0L), chrono.set(end, 0L));
   }
 }
 // Adapted from the package-private BasicDayOfMonthDateTimeField
 @Override
 public int getMaximumValue(ReadablePartial partial, int[] values) {
   int size = partial.size();
   for (int i = 0; i < size; i++) {
     if (partial.getFieldType(i) == DateTimeFieldType.monthOfYear()) {
       int month = values[i];
       return this.daysInMonth[month - 1];
     }
   }
   return this.getMaximumValue();
 }