jdk/src/share/classes/java/time/LocalDate.java
changeset 20517 1336a85b3d52
parent 19841 15c8e97d6a14
child 20519 eee7a92074fd
equal deleted inserted replaced
20516:fa2edce67c48 20517:1336a85b3d52
  1123      * @throws DateTimeException if the addition cannot be made
  1123      * @throws DateTimeException if the addition cannot be made
  1124      * @throws ArithmeticException if numeric overflow occurs
  1124      * @throws ArithmeticException if numeric overflow occurs
  1125      */
  1125      */
  1126     @Override
  1126     @Override
  1127     public LocalDate plus(TemporalAmount amountToAdd) {
  1127     public LocalDate plus(TemporalAmount amountToAdd) {
       
  1128         Objects.requireNonNull(amountToAdd, "amountToAdd");
       
  1129         if (amountToAdd instanceof Period) {
       
  1130             Period periodToAdd = (Period) amountToAdd;
       
  1131             return plusMonths(periodToAdd.toTotalMonths()).plusDays(periodToAdd.getDays());
       
  1132         }
  1128         return (LocalDate) amountToAdd.addTo(this);
  1133         return (LocalDate) amountToAdd.addTo(this);
  1129     }
  1134     }
  1130 
  1135 
  1131     /**
  1136     /**
  1132      * Returns a copy of this date with the specified amount added.
  1137      * Returns a copy of this date with the specified amount added.
  1351      * @throws DateTimeException if the subtraction cannot be made
  1356      * @throws DateTimeException if the subtraction cannot be made
  1352      * @throws ArithmeticException if numeric overflow occurs
  1357      * @throws ArithmeticException if numeric overflow occurs
  1353      */
  1358      */
  1354     @Override
  1359     @Override
  1355     public LocalDate minus(TemporalAmount amountToSubtract) {
  1360     public LocalDate minus(TemporalAmount amountToSubtract) {
       
  1361         Objects.requireNonNull(amountToSubtract, "amountToSubtract");
       
  1362         if (amountToSubtract instanceof Period) {
       
  1363             Period periodToSubtract = (Period) amountToSubtract;
       
  1364             return minusMonths(periodToSubtract.toTotalMonths()).minusDays(periodToSubtract.getDays());
       
  1365         }
  1356         return (LocalDate) amountToSubtract.subtractFrom(this);
  1366         return (LocalDate) amountToSubtract.subtractFrom(this);
  1357     }
  1367     }
  1358 
  1368 
  1359     /**
  1369     /**
  1360      * Returns a copy of this date with the specified amount subtracted.
  1370      * Returns a copy of this date with the specified amount subtracted.