Exemplo n.º 1
0
 /**
  * Resolves singletons.
  *
  * @return the singleton instance
  */
 private Object readResolve() {
   return Months.of(months);
 }
Exemplo n.º 2
0
 /**
  * Returns a new instance with the specified amount of time added.
  *
  * <p>This instance is immutable and unaffected by this method call.
  *
  * @param amount the amount of time to add, may be negative
  * @return the new amount plus the specified amount of time, not null
  * @throws ArithmeticException if the result overflows an {@code int}
  */
 public Months plus(Months amount) {
   return plus(amount.getAmount());
 }
Exemplo n.º 3
0
 /**
  * Returns a new instance with the specified amount of time subtracted.
  *
  * <p>This instance is immutable and unaffected by this method call.
  *
  * @param amount the amount of time to add, may be negative
  * @return the new amount minus the specified amount of time, not null
  * @throws ArithmeticException if the result overflows an {@code int}
  */
 public Months minus(Months amount) {
   return minus(amount.getAmount());
 }
Exemplo n.º 4
0
 /**
  * Returns a new instance of the subclass with a different number of months.
  *
  * @param amount the number of months to set in the new instance, may be negative
  * @return a new period element, not null
  */
 @Override
 public Months withAmount(int amount) {
   return Months.of(amount);
 }