Top Description Fields Constructors Methods
com.calendarfx.model

public final Class Interval

extends Object
Class Inheritance
Imports
java.time.Duration, .Instant, .LocalDate, .LocalDateTime, .LocalTime, .ZoneId, .ZonedDateTime

A class used for storing the time interval and time zone of an entry.
See Also
Entry#setInterval(Interval)

Field Summary

Modifier and TypeField and Description
private static final LocalDate
private static final LocalTime
private static final LocalTime
private static final ZoneId
private final LocalDate
private LocalDateTime
private long
private final LocalTime
private final LocalDate
private LocalDateTime
private long
private final LocalTime
private ZonedDateTime
private ZonedDateTime
private final ZoneId

Constructor Summary

AccessConstructor and Description
public
Interval()

Constructs a new time interval with start and end dates equal to LocalDate#now().

public
Interval(LocalDate
the start date (e.g. Oct. 3rd, 2015)
startDate
,
LocalTime
the start time (e.g. 10:45am)
startTime
,
LocalDate
the end date
endDate
,
LocalTime
the end time
endTime
)

Constructs a new time interval with the given start and end dates / times.

public
Interval(LocalDateTime
the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)
startDateTime
,
LocalDateTime
the end date and time
endDateTime
)

Constructs a new time interval with the given start and end dates / times.

public
Interval(ZonedDateTime
the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)
zonedStartDateTime
,
ZonedDateTime
the end date and time
zonedEndDateTime
)

Constructs a new time interval with the given start and end zoned dates / times.

public
Interval(LocalDateTime
the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)
startDateTime
,
LocalDateTime
the end date and time
endDateTime
,
ZoneId
the time zone
zoneId
)

Constructs a new time interval with the given start and end dates / times and time zone.

public
Interval(Instant
the start time
startTime
,
Instant
the end time
endTime
,
ZoneId
the time zone
zoneId
)

Constructs a new time interval with the given start and end times and time zone.

public
Interval(LocalDate
the start date (e.g. Oct. 3rd, 2015)
startDate
,
LocalTime
the start time (e.g. 10:45am)
startTime
,
LocalDate
the end date
endDate
,
LocalTime
the end time
endTime
,
ZoneId
the time zone
zoneId
)

Constructs a new time interval with the given start and end dates / times and time zone.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Duration

Returns:

the duration between the zoned start and end date and time
getDuration
()

Returns the duration of this interval.

public LocalDate

Returns:

the end date
getEndDate
()

Returns the end date of the interval.

public LocalDateTime

Returns:

the end local date time
getEndDateTime
()

Utility method to get the local end date time.

public long

Returns:

the start time in milliseconds
getEndMillis
()

Returns the start time in milliseconds since 1.1.1970.

public LocalTime

Returns:

the end time
getEndTime
()

Returns the end time of the interval.

public ZonedDateTime

Returns:

the zoned end time
getEndZonedDateTime
()

A convenience method to retrieve a zoned date time based on the end date, end time, and time zone id.

public LocalDate

Returns:

the start date
getStartDate
()

Returns the start date of the interval.

public LocalDateTime

Returns:

the start local date time
getStartDateTime
()

Utility method to get the local start date time.

public long

Returns:

the start time in milliseconds
getStartMillis
()

Returns the start time in milliseconds since 1.1.1970.

public LocalTime

Returns:

the start time
getStartTime
()

Returns the start time of the interval.

public ZonedDateTime

Returns:

the zoned start time
getStartZonedDateTime
()

A convenience method to retrieve a zoned date time based on the start date, start time, and time zone id.

public ZoneId

Returns:

the time zone
getZoneId
()

Returns the time zone ID.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Interval

Returns:

a new interval
withDates
(LocalDate
the new start date
startDate
,
LocalDate
the new end date
endDate
)

Returns a new interval based on this interval but with a different start and end date.

public Interval

Returns:

a new interval
withDates
(LocalDateTime
the new start date
startDateTime
,
LocalDateTime
the new end date
endDateTime
)

Returns a new interval based on this interval but with a different start and end date.

public Interval

Returns:

a new interval
withDuration
(Duration
the new duration
duration
)

Returns a new interval based on this interval but with a different duration.

public Interval

Returns:

a new interval
withEndDate
(LocalDate
the new end date
date
)

Returns a new interval based on this interval but with a different end date.

public Interval

Returns:

a new interval
withEndDateTime
(LocalDateTime
the new end date and time
dateTime
)

Returns a new interval based on this interval but with a different end date and time.

public Interval

Returns:

a new interval
withEndTime
(LocalTime
the new end time
time
)

Returns a new interval based on this interval but with a different end time.

public Interval

Returns:

a new interval
withStartDate
(LocalDate
the new start date
date
)

Returns a new interval based on this interval but with a different start date.

public Interval

Returns:

a new interval
withStartDateTime
(LocalDateTime
the new start date and time
dateTime
)

Returns a new interval based on this interval but with a different start date and time.

public Interval

Returns:

a new interval
withStartTime
(LocalTime
the new start time
time
)

Returns a new interval based on this interval but with a different start time.

public Interval

Returns:

a new interval
withTimes
(LocalTime
the new start time
startTime
,
LocalTime
the new end time
endTime
)

Returns a new interval based on this interval but with a different start and end time.

public Interval

Returns:

a new interval
withZoneId
(ZoneId
the new time zone
zone
)

Returns a new interval based on this interval but with a different time zone id.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

defaultDateback to summary
private static final LocalDate defaultDate
defaultEndTimeback to summary
private static final LocalTime defaultEndTime
defaultStartTimeback to summary
private static final LocalTime defaultStartTime
defaultZoneIdback to summary
private static final ZoneId defaultZoneId
endDateback to summary
private final LocalDate endDate
endDateTimeback to summary
private LocalDateTime endDateTime
endMillisback to summary
private long endMillis
endTimeback to summary
private final LocalTime endTime
startDateback to summary
private final LocalDate startDate
startDateTimeback to summary
private LocalDateTime startDateTime
startMillisback to summary
private long startMillis
startTimeback to summary
private final LocalTime startTime
zonedEndDateTimeback to summary
private ZonedDateTime zonedEndDateTime
zonedStartDateTimeback to summary
private ZonedDateTime zonedStartDateTime
zoneIdback to summary
private final ZoneId zoneId

Constructor Detail

Intervalback to summary
public Interval()

Constructs a new time interval with start and end dates equal to 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().

Intervalback to summary
public Interval(LocalDate startDate, LocalTime startTime, LocalDate endDate, LocalTime endTime)

Constructs a new time interval with the given start and end dates / times. The time zone will be initialized with ZoneId#systemDefault().

Parameters
startDate:LocalDate

the start date (e.g. Oct. 3rd, 2015)

startTime:LocalTime

the start time (e.g. 10:45am)

endDate:LocalDate

the end date

endTime:LocalTime

the end time

Intervalback to summary
public Interval(LocalDateTime startDateTime, LocalDateTime endDateTime)

Constructs a new time interval with the given start and end dates / times. The time zone will be initialized with ZoneId#systemDefault().

Parameters
startDateTime:LocalDateTime

the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)

endDateTime:LocalDateTime

the end date and time

Intervalback to summary
public Interval(ZonedDateTime zonedStartDateTime, ZonedDateTime zonedEndDateTime)

Constructs a new time interval with the given start and end zoned dates / times. The time zone will be initialized with the time zone of the start date time. However, if the zone ID of the second argument is different then an exception will be thrown.

Parameters
zonedStartDateTime:ZonedDateTime

the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)

zonedEndDateTime:ZonedDateTime

the end date and time

Exceptions
IllegalArgumentException:
if two different time zones are used
Intervalback to summary
public Interval(LocalDateTime startDateTime, LocalDateTime endDateTime, ZoneId zoneId)

Constructs a new time interval with the given start and end dates / times and time zone.

Parameters
startDateTime:LocalDateTime

the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)

endDateTime:LocalDateTime

the end date and time

zoneId:ZoneId

the time zone

Intervalback to summary
public Interval(Instant startTime, Instant endTime, ZoneId zoneId)

Constructs a new time interval with the given start and end times and time zone.

Parameters
startTime:Instant

the start time

endTime:Instant

the end time

zoneId:ZoneId

the time zone

Intervalback to summary
public 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.

Parameters
startDate:LocalDate

the start date (e.g. Oct. 3rd, 2015)

startTime:LocalTime

the start time (e.g. 10:45am)

endDate:LocalDate

the end date

endTime:LocalTime

the end time

zoneId:ZoneId

the time zone

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getDurationback to summary
public Duration getDuration()

Returns the duration of this interval.

Returns:Duration

the duration between the zoned start and end date and time

getEndDateback to summary
public LocalDate getEndDate()

Returns the end date of the interval.

Returns:LocalDate

the end date

getEndDateTimeback to summary
public LocalDateTime getEndDateTime()

Utility method to get the local end date time. This method combines the end date and the end time to create a date time object.

Returns:LocalDateTime

the end local date time

See Also
getEndDate(), getEndTime()
getEndMillisback to summary
public long getEndMillis()

Returns the start time in milliseconds since 1.1.1970.

Returns:long

the start time in milliseconds

getEndTimeback to summary
public LocalTime getEndTime()

Returns the end time of the interval.

Returns:LocalTime

the end time

getEndZonedDateTimeback to summary
public ZonedDateTime getEndZonedDateTime()

A convenience method to retrieve a zoned date time based on the end date, end time, and time zone id.

Returns:ZonedDateTime

the zoned end time

getStartDateback to summary
public LocalDate getStartDate()

Returns the start date of the interval.

Returns:LocalDate

the start date

getStartDateTimeback to summary
public LocalDateTime getStartDateTime()

Utility method to get the local start date time. This method combines the start date and the start time to create a date time object.

Returns:LocalDateTime

the start local date time

See Also
getStartDate(), getStartTime()
getStartMillisback to summary
public long getStartMillis()

Returns the start time in milliseconds since 1.1.1970.

Returns:long

the start time in milliseconds

getStartTimeback to summary
public LocalTime getStartTime()

Returns the start time of the interval.

Returns:LocalTime

the start time

getStartZonedDateTimeback to summary
public ZonedDateTime getStartZonedDateTime()

A convenience method to retrieve a zoned date time based on the start date, start time, and time zone id.

Returns:ZonedDateTime

the zoned start time

getZoneIdback to summary
public ZoneId getZoneId()

Returns the time zone ID.

Returns:ZoneId

the time zone

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
withDatesback to summary
public Interval withDates(LocalDate startDate, LocalDate endDate)

Returns a new interval based on this interval but with a different start and end date.

Parameters
startDate:LocalDate

the new start date

endDate:LocalDate

the new end date

Returns:Interval

a new interval

withDatesback to summary
public Interval withDates(LocalDateTime startDateTime, LocalDateTime endDateTime)

Returns a new interval based on this interval but with a different start and end date.

Parameters
startDateTime:LocalDateTime

the new start date

endDateTime:LocalDateTime

the new end date

Returns:Interval

a new interval

withDurationback to summary
public Interval withDuration(Duration duration)

Returns a new interval based on this interval but with a different duration. The duration will change the end time and / or the end date.

Parameters
duration:Duration

the new duration

Returns:Interval

a new interval

withEndDateback to summary
public Interval withEndDate(LocalDate date)

Returns a new interval based on this interval but with a different end date.

Parameters
date:LocalDate

the new end date

Returns:Interval

a new interval

withEndDateTimeback to summary
public Interval withEndDateTime(LocalDateTime dateTime)

Returns a new interval based on this interval but with a different end date and time.

Parameters
dateTime:LocalDateTime

the new end date and time

Returns:Interval

a new interval

withEndTimeback to summary
public Interval withEndTime(LocalTime time)

Returns a new interval based on this interval but with a different end time.

Parameters
time:LocalTime

the new end time

Returns:Interval

a new interval

withStartDateback to summary
public Interval withStartDate(LocalDate date)

Returns a new interval based on this interval but with a different start date.

Parameters
date:LocalDate

the new start date

Returns:Interval

a new interval

withStartDateTimeback to summary
public Interval withStartDateTime(LocalDateTime dateTime)

Returns a new interval based on this interval but with a different start date and time.

Parameters
dateTime:LocalDateTime

the new start date and time

Returns:Interval

a new interval

withStartTimeback to summary
public Interval withStartTime(LocalTime time)

Returns a new interval based on this interval but with a different start time.

Parameters
time:LocalTime

the new start time

Returns:Interval

a new interval

withTimesback to summary
public Interval withTimes(LocalTime startTime, LocalTime endTime)

Returns a new interval based on this interval but with a different start and end time.

Parameters
startTime:LocalTime

the new start time

endTime:LocalTime

the new end time

Returns:Interval

a new interval

withZoneIdback to summary
public Interval withZoneId(ZoneId zone)

Returns a new interval based on this interval but with a different time zone id.

Parameters
zone:ZoneId

the new time zone

Returns:Interval

a new interval