public final class Interval extends Object
Entry.setInterval(Interval)
Constructor and Description |
---|
Interval()
Constructs a new time interval with start and end dates equal to
LocalDate.now() . |
Interval(LocalDate startDate,
LocalTime startTime,
LocalDate endDate,
LocalTime endTime)
Constructs a new time interval with the given start and end dates /
times.
|
Interval(LocalDate startDate,
LocalTime startTime,
LocalDate endDate,
LocalTime endTime,
ZoneId zoneId)
Constructs a new time interval with the given start and end dates / times
and time zone.
|
Interval(LocalDateTime startDateTime,
LocalDateTime endDateTime)
Constructs a new time interval with the given start and end dates /
times.
|
Interval(LocalDateTime startDateTime,
LocalDateTime endDateTime,
ZoneId zoneId)
Constructs a new time interval with the given start and end dates /
times and time zone.
|
Interval(ZonedDateTime zonedStartDateTime,
ZonedDateTime zonedEndDateTime)
Constructs a new time interval with the given start and end zoned dates /
times.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Duration |
getDuration()
Returns the duration of this interval.
|
LocalDate |
getEndDate()
Returns the end date of the interval.
|
LocalDateTime |
getEndDateTime()
Utility method to get the local end date time.
|
long |
getEndMillis()
Returns the start time in milliseconds since 1.1.1970.
|
LocalTime |
getEndTime()
Returns the end time of the interval.
|
ZonedDateTime |
getEndZonedDateTime()
A convenience method to retrieve a zoned date time based on the end date,
end time, and time zone id.
|
LocalDate |
getStartDate()
Returns the start date of the interval.
|
LocalDateTime |
getStartDateTime()
Utility method to get the local start date time.
|
long |
getStartMillis()
Returns the start time in milliseconds since 1.1.1970.
|
LocalTime |
getStartTime()
Returns the start time of the interval.
|
ZonedDateTime |
getStartZonedDateTime()
A convenience method to retrieve a zoned date time based on the start
date, start time, and time zone id.
|
ZoneId |
getZoneId()
Returns the time zone ID.
|
int |
hashCode() |
String |
toString() |
Interval |
withDates(LocalDate startDate,
LocalDate endDate)
Returns a new interval based on this interval but with a different start
and end date.
|
Interval |
withDates(LocalDateTime startDateTime,
LocalDateTime endDateTime)
Returns a new interval based on this interval but with a different start
and end date.
|
Interval |
withEndDate(LocalDate date)
Returns a new interval based on this interval but with a different end
date.
|
Interval |
withEndDateTime(LocalDateTime dateTime)
Returns a new interval based on this interval but with a different end
date and time.
|
Interval |
withEndTime(LocalTime time)
Returns a new interval based on this interval but with a different end
time.
|
Interval |
withStartDate(LocalDate date)
Returns a new interval based on this interval but with a different start
date.
|
Interval |
withStartDateTime(LocalDateTime dateTime)
Returns a new interval based on this interval but with a different start date
and time.
|
Interval |
withStartTime(LocalTime time)
Returns a new interval based on this interval but with a different start
time.
|
Interval |
withTimes(LocalTime startTime,
LocalTime endTime)
Returns a new interval based on this interval but with a different start
and end time.
|
Interval |
withZoneId(ZoneId zone)
Returns a new interval based on this interval but with a different time
zone id.
|
public Interval()
LocalDate.now()
. The start and end times will be set to
LocalTime.now()
and LocalTime.now()
plus one hour. The
time zone will be set to ZoneId.systemDefault()
.public Interval(LocalDate startDate, LocalTime startTime, LocalDate endDate, LocalTime endTime)
ZoneId.systemDefault()
.startDate
- the start date (e.g. Oct. 3rd, 2015)startTime
- the start time (e.g. 10:45am)endDate
- the end dateendTime
- the end timepublic Interval(LocalDateTime startDateTime, LocalDateTime endDateTime)
ZoneId.systemDefault()
.startDateTime
- the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)endDateTime
- the end date and timepublic Interval(ZonedDateTime zonedStartDateTime, ZonedDateTime zonedEndDateTime)
zonedStartDateTime
- the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)zonedEndDateTime
- the end date and timeIllegalArgumentException
- if two different time zones are usedpublic Interval(LocalDateTime startDateTime, LocalDateTime endDateTime, ZoneId zoneId)
startDateTime
- the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)endDateTime
- the end date and timezoneId
- the time zonepublic Interval(LocalDate startDate, LocalTime startTime, LocalDate endDate, LocalTime endTime, ZoneId zoneId)
startDate
- the start date (e.g. Oct. 3rd, 2015)startTime
- the start time (e.g. 10:45am)endDate
- the end dateendTime
- the end timezoneId
- the time zonepublic ZoneId getZoneId()
public LocalDate getStartDate()
public LocalTime getStartTime()
public ZonedDateTime getStartZonedDateTime()
public long getStartMillis()
public LocalDate getEndDate()
public LocalTime getEndTime()
public ZonedDateTime getEndZonedDateTime()
public long getEndMillis()
public Interval withDates(LocalDate startDate, LocalDate endDate)
startDate
- the new start dateendDate
- the new end datepublic Interval withDates(LocalDateTime startDateTime, LocalDateTime endDateTime)
startDateTime
- the new start dateendDateTime
- the new end datepublic Interval withTimes(LocalTime startTime, LocalTime endTime)
startTime
- the new start timeendTime
- the new end timepublic Interval withStartDate(LocalDate date)
date
- the new start datepublic Interval withEndDate(LocalDate date)
date
- the new end datepublic Interval withStartTime(LocalTime time)
time
- the new start timepublic Interval withStartDateTime(LocalDateTime dateTime)
dateTime
- the new start date and timepublic Interval withEndTime(LocalTime time)
time
- the new end timepublic Interval withEndDateTime(LocalDateTime dateTime)
dateTime
- the new end date and timepublic Interval withZoneId(ZoneId zone)
zone
- the new time zonepublic LocalDateTime getStartDateTime()
getStartDate()
,
getStartTime()
public Duration getDuration()
public LocalDateTime getEndDateTime()
getEndDate()
,
getEndTime()
Copyright © 2017 Dirk Lemmermann Software & Consulting. All rights reserved.