Class TemporalInterval
- java.lang.Object
-
- com.blazebit.domain.runtime.model.TemporalInterval
-
- All Implemented Interfaces:
Comparable<TemporalInterval>
public class TemporalInterval extends Object implements Comparable<TemporalInterval>
A positive temporal interval.- Since:
- 1.0.0
- Author:
- Christian Beikov
-
-
Constructor Summary
Constructors Constructor Description TemporalInterval(int years, int months, int days, int hours, int minutes, int seconds)
Constructs a temporal interval with the given temporal amounts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TemporalInterval
add(TemporalInterval interval2)
Adds the given interval to this and returns a new interval.Instant
add(Instant instant)
Adds this interval to the given instant producing a new instant.LocalTime
add(LocalTime localTime)
Adds this interval to the given local time producing a new local time.int
compareTo(TemporalInterval o)
boolean
equals(Object o)
Returnstrue
if all amounts are equal to the amounts of the other interval.int
getDays()
Returns the days.int
getHours()
Returns the hours.int
getMinutes()
Returns the minutes.int
getMonths()
Returns the months.int
getSeconds()
Returns the seconds.int
getYears()
Returns the years.int
hashCode()
Returns the hash code based on the individual amounts.TemporalInterval
subtract(TemporalInterval interval2)
Subtracts the given interval from this and returns a new interval.Instant
subtract(Instant instant)
Subtract this interval from the given instant producing a new instant.LocalTime
subtract(LocalTime localTime)
Subtract this interval from the given local time producing a new local time.String
toString()
The format is(Y YEARS )?
-
-
-
Constructor Detail
-
TemporalInterval
public TemporalInterval(int years, int months, int days, int hours, int minutes, int seconds)
Constructs a temporal interval with the given temporal amounts.- Parameters:
years
- The yearsmonths
- The monthsdays
- The dayshours
- The hoursminutes
- The minutesseconds
- The seconds
-
-
Method Detail
-
getYears
public int getYears()
Returns the years.- Returns:
- the years
-
getMonths
public int getMonths()
Returns the months.- Returns:
- the months
-
getDays
public int getDays()
Returns the days.- Returns:
- the days
-
getHours
public int getHours()
Returns the hours.- Returns:
- the hours
-
getMinutes
public int getMinutes()
Returns the minutes.- Returns:
- the minutes
-
getSeconds
public int getSeconds()
Returns the seconds.- Returns:
- the seconds
-
equals
public boolean equals(Object o)
Returnstrue
if all amounts are equal to the amounts of the other interval.
-
hashCode
public int hashCode()
Returns the hash code based on the individual amounts.
-
toString
public String toString()
The format is(Y YEARS )?(m MONTHS )?(d DAYS )?(h HOURS )?(m MINUTES )?s SECONDS
.
-
add
public TemporalInterval add(TemporalInterval interval2)
Adds the given interval to this and returns a new interval.- Parameters:
interval2
- The interval to add- Returns:
- A new interval representing the sum of this and the other interval
-
subtract
public TemporalInterval subtract(TemporalInterval interval2)
Subtracts the given interval from this and returns a new interval.- Parameters:
interval2
- The interval to subtract- Returns:
- A new interval representing the sum of this subtracted by the other interval
-
add
public Instant add(Instant instant)
Adds this interval to the given instant producing a new instant.- Parameters:
instant
- The instant to which to add this interval.- Returns:
- A new instant representing the sum of the given instant plus this interval
-
subtract
public Instant subtract(Instant instant)
Subtract this interval from the given instant producing a new instant.- Parameters:
instant
- The instant from which to subtract this interval.- Returns:
- A new instant representing the sum of the given instant subtracted by this interval
-
add
public LocalTime add(LocalTime localTime)
Adds this interval to the given local time producing a new local time.- Parameters:
localTime
- The local time to which to add this interval.- Returns:
- A new local time representing the sum of the given local time plus this interval
-
subtract
public LocalTime subtract(LocalTime localTime)
Subtract this interval from the given local time producing a new local time.- Parameters:
localTime
- The local time from which to subtract this interval.- Returns:
- A new local time representing the sum of the given local time subtracted by this interval
-
compareTo
public int compareTo(TemporalInterval o)
- Specified by:
compareTo
in interfaceComparable<TemporalInterval>
-
-