public class TimeInterval extends Object
This class represents the ISO 8601 time interval concept, which allows the different formats to express a time interval:
where start and end is specified using ISO 8601 date and time, while a duration is specified using a ISO 8601 duration.
Modifier and Type | Method | Description |
---|---|---|
static TimeInterval |
create(Duration duration,
IsoDateTime end) |
Creates a time interval with the specified duration ending at
the specified end date-time.
|
static TimeInterval |
create(IsoDateTime start,
Duration duration) |
Creates a time interval from the specified start date-time with the
specified duration.
|
static TimeInterval |
create(IsoDateTime start,
IsoDateTime end) |
Creates a time interval between the specified start and end
date-times.
|
static TimeInterval |
day(int year,
Month month,
int day) |
Convenience method for returning a time interval covering a complete
calendar day.
|
Duration |
duration(TimeZone tz) |
Returns the duration of this time interval.
|
TimePoint |
end(TimeZone tz) |
Returns the end point in time, given the time zone for local
time.
|
boolean |
equals(Object o) |
True if the argument is a time interval specified by the very same
components as this time interval.
|
int |
hashCode() |
|
static TimeInterval |
month(int year,
Month month) |
Convenience method for returning a time interval covering a complete
calendar month.
|
static TimeInterval |
parse(String iso) |
Parses a time interval on any of the three valid formats.
|
static TimeInterval |
quarter(int year,
int quarter) |
Convenience method for returning a time interval covering a complete
calendar quarter.
|
TimePoint |
start(TimeZone tz) |
Returns the start point in time, given the time zone for local
time.
|
static TimeInterval |
today(TimeZone tz) |
Convenience method for returning a time interval covering today.
|
long |
toMillis(TimeZone tz) |
Returns the length in milliseconds for this time interval,
given a local time zone.
|
String |
toString() |
Returns an ISO 8601 formatted string representing this time interval.
|
static TimeInterval |
week(int year,
int week,
Locale locale) |
Convenience method for returning a time interval covering a complete
calendar week according to the week rules defined by the specified
locale.
|
static TimeInterval |
year(int year) |
Convenience method for returning a time interval covering a complete
calendar year.
|
public static TimeInterval year(int year)
year
- The year.public static TimeInterval quarter(int year, int quarter)
year
- The year.quarter
- The quarter.public static TimeInterval month(int year, Month month)
year
- The year.month
- The month.public static TimeInterval week(int year, int week, Locale locale)
year
- The week year.week
- The week.locale
- The locale, controlling week rules.public static TimeInterval day(int year, Month month, int day)
year
- The year.month
- The month.day
- The day.public static TimeInterval today(TimeZone tz)
tz
- Time zone to decide which day is "today".public static TimeInterval create(IsoDateTime start, IsoDateTime end)
start
- start date-time.end
- end date-time.public static TimeInterval create(IsoDateTime start, Duration duration)
start
- start date-time.duration
- duration of interval.public static TimeInterval create(Duration duration, IsoDateTime end)
duration
- duration of interval.end
- end date-time.public static TimeInterval parse(String iso)
iso
- The input string.IllegalArgumentException
- if the input cannot be parsed.public TimePoint start(TimeZone tz)
tz
- The local time zone.public TimePoint end(TimeZone tz)
tz
- The local time zone.public Duration duration(TimeZone tz)
tz
- The local time zone.public boolean equals(Object o)
Two time intervals may cover the same set of time points in all time zones and for all locales and still not be considered equal, depending on how they are specified.
public String toString()
public long toMillis(TimeZone tz)
tz
- The local time zone.Copyright © 2021 Apptus Technologies AB. All rights reserved.