public final class Minutes extends PeriodField implements java.lang.Comparable<Minutes>, java.io.Serializable
Minutes is an immutable period that can only store minutes. It is a type-safe way of representing a number of minutes in an application.
Static factory methods allow you to construct instances. The number of minutes may be queried using getMinutes(). Basic mathematical operations are provided - plus(), minus(), multipliedBy(), dividedBy() and negated(), all of which return a new instance
Minutes is immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
static Minutes |
ZERO
A constant for zero minutes.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Minutes otherMinutes)
Compares the number of minutes in this instance to another instance.
|
Minutes |
dividedBy(int divisor)
Returns a new instance with the minutes divided by the specified divisor.
|
int |
getAmount()
Gets the number of minutes held in this period.
|
PeriodUnit |
getUnit()
Gets the unit defining the amount of time.
|
boolean |
isGreaterThan(Minutes otherMinutes)
Is the number of minutes in this instance greater than that in
another instance.
|
boolean |
isLessThan(Minutes otherMinutes)
Is the number of minutes in this instance less than that in
another instance.
|
Minutes |
minus(int minutes)
Returns a new instance with the specified number of minutes taken away.
|
Minutes |
minus(Minutes minutes)
Returns a new instance with the specified number of minutes taken away.
|
Minutes |
multipliedBy(int scalar)
Returns a new instance with the minutes multiplied by the specified scalar.
|
Minutes |
negated()
Returns a new instance with the minutes value negated.
|
static Minutes |
of(int minutes)
Obtains an instance of
Minutes . |
Minutes |
plus(int minutes)
Returns a new instance with the specified number of minutes added.
|
Minutes |
plus(Minutes minutes)
Returns a new instance with the specified number of minutes added.
|
java.lang.String |
toString()
Returns a string representation of the number of minutes.
|
Minutes |
withAmount(int amount)
Returns a new instance of the subclass with a different number of minutes.
|
equals, hashCode, toPeriodFields
public static final Minutes ZERO
public static Minutes of(int minutes)
Minutes
.minutes
- the number of minutes the instance will representpublic int getAmount()
getAmount
in class PeriodField
public Minutes withAmount(int amount)
withAmount
in class PeriodField
amount
- the number of minutes to set in the new instance, may be negativepublic PeriodUnit getUnit()
getUnit
in class PeriodField
public Minutes plus(int minutes)
This instance is immutable and unaffected by this method call.
plus
in class PeriodField
minutes
- the amount of minutes to add, may be negativejava.lang.ArithmeticException
- if the result overflows an intpublic Minutes plus(Minutes minutes)
This instance is immutable and unaffected by this method call.
minutes
- the amount of minutes to add, may be negative, not nulljava.lang.NullPointerException
- if the minutes to add is nulljava.lang.ArithmeticException
- if the result overflows an intpublic Minutes minus(int minutes)
This instance is immutable and unaffected by this method call.
minus
in class PeriodField
minutes
- the amount of minutes to take away, may be negativejava.lang.ArithmeticException
- if the result overflows an intpublic Minutes minus(Minutes minutes)
This instance is immutable and unaffected by this method call.
minutes
- the amount of minutes to take away, may be negative, not nulljava.lang.NullPointerException
- if the minutes to add is nulljava.lang.ArithmeticException
- if the result overflows an intpublic Minutes multipliedBy(int scalar)
This instance is immutable and unaffected by this method call.
multipliedBy
in class PeriodField
scalar
- the amount to multiply by, may be negativejava.lang.ArithmeticException
- if the result overflows an intpublic Minutes dividedBy(int divisor)
This instance is immutable and unaffected by this method call.
dividedBy
in class PeriodField
divisor
- the amount to divide by, may be negativejava.lang.ArithmeticException
- if the divisor is zeropublic Minutes negated()
negated
in class PeriodField
java.lang.ArithmeticException
- if the result overflows an intpublic int compareTo(Minutes otherMinutes)
compareTo
in interface java.lang.Comparable<Minutes>
otherMinutes
- the other number of minutes, not nulljava.lang.NullPointerException
- if otherMinutes is nullpublic boolean isGreaterThan(Minutes otherMinutes)
otherMinutes
- the other number of minutes, not nulljava.lang.NullPointerException
- if otherMinutes is nullpublic boolean isLessThan(Minutes otherMinutes)
otherMinutes
- the other number of minutes, not nulljava.lang.NullPointerException
- if otherMinutes is nullpublic java.lang.String toString()
toString
in class PeriodField