Record Class DateRange
java.lang.Object
java.lang.Record
nl.colorize.util.stats.DateRange
- All Implemented Interfaces:
Comparable<DateRange>, Predicate<Date>
public record DateRange(Date start, Date end)
extends Record
implements Predicate<Date>, Comparable<DateRange>
Defines a range between two
Dates, with the start date being inclusive
and the end date being exclusive. Although the name of this class implies a
date range, this is technically a date/time range since
Date instances always include a time.
If dates do not specify an explicit time zone, the default time zone will be
used. See Platform.getDefaultTimeZone() for how to configure the
default time zone.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanReturns true if this date range contains the specified date.end()Returns the value of theendrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Creates a new date range that represents the smallest possible period that includes both this date range and the specified other date range.Splits this date range into daily intervals.Splits this date range into monthly intervals.Splits this date range into weekly intervals.Splits this date range into yearly intervals.start()Returns the value of thestartrecord component.booleanReturns true if this date range includes the specified date, using the same logic describes incontains(Date).toString()Returns a string representation of this record class.
-
Constructor Details
-
DateRange
-
DateRange
Secondary constructor that usesDateParser.parse(String)to parse dates from strings.
-
-
Method Details
-
contains
Returns true if this date range contains the specified date. Note the start date is considered inclusive but the end date is considered exclusive, so this method will return false if the argument matches the end date exactly. -
test
Returns true if this date range includes the specified date, using the same logic describes incontains(Date). -
splitDays
-
splitWeeks
-
splitMonths
-
splitYears
-
span
-
compareTo
- Specified by:
compareToin interfaceComparable<DateRange>
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
start
Returns the value of thestartrecord component.- Returns:
- the value of the
startrecord component
-
end
Returns the value of theendrecord component.- Returns:
- the value of the
endrecord component
-