Beispiel #1
0
 /**
  * Gets the value of the requested unit.
  *
  * <p>This returns a value for each of the three supported units, {@link ChronoUnit#YEARS YEARS},
  * {@link ChronoUnit#MONTHS MONTHS} and {@link ChronoUnit#DAYS DAYS}. All other units throw an
  * exception.
  *
  * @param unit the {@code TemporalUnit} for which to return the value
  * @return the long value of the unit
  * @throws DateTimeException if the unit is not supported
  */
 @Override
 public long get(TemporalUnit unit) {
   if (unit == ChronoUnit.YEARS) {
     return getYears();
   } else if (unit == ChronoUnit.MONTHS) {
     return getMonths();
   } else if (unit == ChronoUnit.DAYS) {
     return getDays();
   } else {
     throw new DateTimeException("Unsupported unit: " + unit.getName());
   }
 }