Class DateValue
- All Implemented Interfaces:
IConvertable
,IPrimitiveValue
,ISingleValue
,IValue
,Serializable
,Comparable<Object>
- Direct Known Subclasses:
AttributeDateValue
,DateTimeValue
This primitive class holds the information about a single date value.
This class should not contain any time data, use DateTimeValue for a date with a time component.
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final DateTimeFormatter
Date time formatter used by DateValue.static final long
This member defines the number of milliseconds in a (SI) day.static final long
This member defines the number of milliseconds in an hour.static final long
This member defines the number of milliseconds in a minute.static final long
This member defines the number of milliseconds in a second.static final DateValue
This member defines the UNKNOWN value for the date type. -
Constructor Summary
ModifierConstructorDescriptionprotected
DateValue
(int y, int m, int d) Construct a DateValue, with year months and day.protected
DateValue
(int y, int m, int d, int hour, int minute, int second, int millis) DateValue
(IMultilingualText displayValue, Date date) Construct a DateValue based on a Date and with a display text.Copy constructor.protected
DateValue
(String typeName, IMultilingualText displayValue, Date date) Construct a DateValue based on a Date as a domain value.protected
DateValue
(String typeName, IMultilingualText displayValue, Date date, boolean includeTime) protected
DateValue
(ZonedDateTime zdt, boolean includeTime) Construct a DateValue based on a ZonedDateTime.Construct a DateValue based on a Date. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This method converts the internal value to a boolean primitive.protected int
compareSimple
(Object obj) boolean
This method returns a boolean indicating if the object passed to this method is entirely part of this value.protected DateValue
createFor
(ZonedDateTime zdt) static DateValue
This method can be used to create a DateValue for the current date.This method converts the internal value to a date object.daysBefore
(DateValue other) This method returns the number of days the other date value is before this.double
This method converts the internal value to a double primitive.This method returns a deep copy of the value.boolean
protected final void
finalize()
forType
(String typeName, IMultilingualText displayValue) This method adds the type and display information to the value, and returns the value with this added information.This method returns the data type of the value.Deprecated.This method returns the month of the current date value.getValue()
This method returns the internal object of this instance without any conversion.This method returns the week number of the current date value.getYear()
int
hashCode()
protected IntegerValue
hoursBefore
(DateValue other) This method returns the number of hours the other date value is before this.int
This method converts the internal value to an integer primitive.boolean
This method returns a boolean indicating if the value is unknown.long
This method converts the internal value to a long primitive.millisBefore
(DateValue other) This method returns the number of milliseconds the other date value is before this.protected IntegerValue
protected IntegerValue
minute()
minutesBefore
(DateValue other) This method returns the number of minutes the other date value is before this.monthsBefore
(DateValue other) This method returns the number of months the other date value is before this.protected static DateTimeValue
now()
static Date
This method tries to create a Date from the provided object.protected IntegerValue
second()
secondsBefore
(DateValue other) This method returns the number of seconds the other date value is before this.Format this DateValue to a String in the format 'yyyy-MM-dd'.Format this DateValue (or DateTimeValue) to an ISO-8601 local date and time without milliseconds and nanoseconds (format 'yyyy-MM-ddTHH:mm:ss').toString()
static DateValue
Parse an object and returns its DateValue.weeksBefore
(DateValue other) This method returns the number of weeks the other date value is before this.withDays
(int days) withHours
(int hours) withMilliseconds
(int milliSeconds) withMinutes
(int minutes) withMonths
(int months) withSeconds
(int seconds) withWeeks
(int weeks) withYears
(int years) workingDaysBetween
(DateValue other) This method passes the default working days (Mo - Tu - We - Th - Fr) to theworkingDaysBetween(DateValue, ListValue)
method.workingDaysBetween
(DateValue other, ListValue workingDays) This method returns the number of full working days between this date value and another date value.yearsBefore
(DateValue other) This method returns the number of years the other date value is before this.Methods inherited from class com.aquima.interactions.foundation.types.AbstractValue
compareTo, getDisplayValue, getTypeName, isRangeValue, isSingleValue, toListValue, toRangeValue, toSingleValue
-
Field Details
-
UNKNOWN
This member defines the UNKNOWN value for the date type. -
MILLISECONDS_PER_SECOND
public static final long MILLISECONDS_PER_SECONDThis member defines the number of milliseconds in a second.- See Also:
-
MILLISECONDS_PER_MINUTE
public static final long MILLISECONDS_PER_MINUTEThis member defines the number of milliseconds in a minute.- See Also:
-
MILLISECONDS_PER_HOUR
public static final long MILLISECONDS_PER_HOURThis member defines the number of milliseconds in an hour.- See Also:
-
MILLISECONDS_PER_DAY
public static final long MILLISECONDS_PER_DAYThis member defines the number of milliseconds in a (SI) day.- See Also:
-
ISO8601_CUSTOM_LOCAL_DATE_TIME
Date time formatter used by DateValue. ISO-8601 local date and time without milliseconds and nanoseconds.
-
-
Constructor Details
-
DateValue
protected DateValue() -
DateValue
Copy constructor.- Parameters:
other
- DateValue to copy.
-
DateValue
-
DateValue
public DateValue(int y, int m, int d) Construct a DateValue, with year months and day.- Month 1 is January, day 1 is the first day of the month specified.
- Dates are always interpreted using the (proleptic) Gregorian calendar rules. Before 17.0, dates before 1582-10-15 where interpreted using the Julian calendar rules
- The system default timezone is used
- Parameters:
y
- The year of the date (1 through 9999).m
- The month of the date (a value from 1 up to 12).d
- The day of the date (a value from 1 up to 31).
-
DateValue
protected DateValue(int y, int m, int d, int hour, int minute, int second, int millis) -
DateValue
Construct a DateValue based on a ZonedDateTime. The year of the ZonedDateTime must be in the range 1 through 9999. Note that the given ZonedDateTime will be converted to the system default timezone.- Parameters:
zdt
- The ZonedDateTime to construct this DateValue with, may be null.includeTime
- When true zdt is used as is, when false the time part is set to 00:00:00.
-
DateValue
Construct a DateValue based on a Date. The year of the Date must be in the range 1 through 9999. The system default timezone is used- Parameters:
date
- The Date to construct this DateValue with.
-
DateValue
Construct a DateValue based on a Date and with a display text. The year of the Date must be in the range 1 through 9999. The system default timezone is used- Parameters:
displayValue
- Text object containing the display value that should be used.date
- The Date to construct this DateValue with.
-
DateValue
Construct a DateValue based on a Date as a domain value. The year of the Date must be in the range 1 through 9999. The system default timezone is used- Parameters:
typeName
- The name of the domain the value belongs to.displayValue
- Text object containing the display value that should be used.date
- The Date to construct this DateValue with.
-
DateValue
protected DateValue(String typeName, IMultilingualText displayValue, Date date, boolean includeTime)
-
-
Method Details
-
valueOf
Parse an object and returns its DateValue.
This method currently returns the date with a time component. Also, when the object provided contains a time component (except when it is a String), this will be parsed. We intend to change this behavior in release 15.0, by no longer parsing the time component and also not returning it. If you need a date with time component, use
DateTimeValue.valueOf(Object)
instead.- Date Strings are always interpreted using the (proleptic) Gregorian calendar rules. Before 17.0, date Strings before 1582-10-15 where interpreted using the Julian calendar rules
- The system default timezone is used
- Parameters:
obj
- The object to parse.- Returns:
- The DateValue representation of the object, never null, but can be unknown.
- Throws:
ConversionException
- Is thrown when parsing fails.
-
parseDate
This method tries to create a Date from the provided object. If the object is a String representation of a Date, it will be parsed. It expects a String format with year-month-day only, so without time component.- Date Strings are always interpreted using the (proleptic) Gregorian calendar rules. Before 17.0, date Strings before 1582-10-15 where interpreted using the Julian calendar rules
- The system default timezone is used
- Parameters:
obj
- The object to parse into a Date.- Returns:
- Date parsed from the provided object.
- Throws:
ConversionException
- when the String representation of the object cannot be parsed according to the applicable format.
-
createToday
This method can be used to create a DateValue for the current date. The current time is not included in the resulting date value.- Returns:
- DateValue for today.
-
forType
Description copied from interface:IPrimitiveValue
This method adds the type and display information to the value, and returns the value with this added information. The method will not change the state of the value the method is invoked on, but it will return a copy of the current value with the added information.- Specified by:
forType
in interfaceIPrimitiveValue
- Specified by:
forType
in classAbstractValue
- Parameters:
typeName
- The type of the value.displayValue
- Multilingual text containing display values.- Returns:
- The value with the added information.
-
contains
Description copied from interface:IValue
This method returns a boolean indicating if the object passed to this method is entirely part of this value. This method will thus also return true when the object passed is equal to this value, but the method will return false when only part (or none) of the object is represented by this value. Note that for value types that are singular in nature (for instance, implementations of ISingleValue) the operation of this method is limited to an equality check.- Specified by:
contains
in interfaceIValue
- Specified by:
contains
in classAbstractValue
- Parameters:
objValue
- Object for which should be checked if it is entirely part of this value.- Returns:
- boolean indicating if the object passed is entirely part of this value.
-
getDataType
Description copied from interface:IValue
This method returns the data type of the value.- Specified by:
getDataType
in interfaceIValue
- Specified by:
getDataType
in classAbstractValue
- Returns:
- The data type of the value.
-
isUnknown
public boolean isUnknown()Description copied from interface:IValue
This method returns a boolean indicating if the value is unknown.- Specified by:
isUnknown
in interfaceIValue
- Specified by:
isUnknown
in classAbstractValue
- Returns:
- boolean indicating if the value is unknown.
-
compareSimple
- Specified by:
compareSimple
in classAbstractValue
-
toString
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractValue
-
equals
- Overrides:
equals
in classAbstractValue
-
longValue
public long longValue()Description copied from interface:IConvertable
This method converts the internal value to a long primitive.- Specified by:
longValue
in interfaceIConvertable
- Specified by:
longValue
in classAbstractValue
- Returns:
- Long primitive of the internal value.
-
getValue
Description copied from interface:IConvertable
This method returns the internal object of this instance without any conversion.- Specified by:
getValue
in interfaceIConvertable
- Specified by:
getValue
in classAbstractValue
- Returns:
- The internal Object of this attribute value.
-
booleanValue
public boolean booleanValue()Description copied from interface:IConvertable
This method converts the internal value to a boolean primitive.- Specified by:
booleanValue
in interfaceIConvertable
- Specified by:
booleanValue
in classAbstractValue
- Returns:
- Boolean primitive of the internal value.
-
dateValue
Description copied from interface:IConvertable
This method converts the internal value to a date object.- Specified by:
dateValue
in interfaceIConvertable
- Specified by:
dateValue
in classAbstractValue
- Returns:
- Date object of the internal value.
-
doubleValue
public double doubleValue()Description copied from interface:IConvertable
This method converts the internal value to a double primitive.- Specified by:
doubleValue
in interfaceIConvertable
- Specified by:
doubleValue
in classAbstractValue
- Returns:
- Double primitive of the internal value.
-
integerValue
public int integerValue()Description copied from interface:IConvertable
This method converts the internal value to an integer primitive.- Specified by:
integerValue
in interfaceIConvertable
- Specified by:
integerValue
in classAbstractValue
- Returns:
- Integer primitive of the internal value.
-
getLeanDateFormat
Deprecated.This method is deprecated. UsetoString()
ortoISO8601()
for formatting. UseparseDate(Object)
orDateTimeValue.parseDateTime(Object)
for parsing. Alternatively useDateTimeFormatter
to format/parse your own dates- Returns:
- An Aquima DateFormat for ISO-8601 local date and time without milliseconds and nanoseconds
-
stringValue
Format this DateValue to a String in the format 'yyyy-MM-dd'.- Dates are always formatted using the (proleptic) Gregorian calendar rules. Before 17.0, dates before 1582-10-15 where formatted using the Julian calendar rules.
- The system default timezone is used.
- Specified by:
stringValue
in interfaceIConvertable
- Specified by:
stringValue
in classAbstractValue
- Returns:
- A String representation of this DateValue
-
toISO8601
Format this DateValue (or DateTimeValue) to an ISO-8601 local date and time without milliseconds and nanoseconds (format 'yyyy-MM-ddTHH:mm:ss').- Dates are always formatted using the (proleptic) Gregorian calendar rules. Before 17.0, dates before 1582-10-15 where formatted using the Julian calendar rules.
- The system default timezone is used.
- Returns:
- Formatted ISO-8601 local date and time
-
hoursBefore
This method returns the number of hours the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of hours this date value is before the other date value.
-
minutesBefore
This method returns the number of minutes the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of minutes this date value is before the other date value.
-
secondsBefore
This method returns the number of seconds the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of seconds this date value is before the other date value.
-
millisBefore
This method returns the number of milliseconds the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of milliseconds this date value is before the other date value.
-
daysBefore
This method returns the number of days the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
Note that time components are ignored for both date values. For example:
new TimestampValue( 2009, 1, 1, 23, 30, 0, 0 ).daysBefore( new DateValue(2009, 1, 2 ) ) will result in 1
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of days this date value is before the other date value.
-
workingDaysBetween
This method passes the default working days (Mo - Tu - We - Th - Fr) to theworkingDaysBetween(DateValue, ListValue)
method.- Parameters:
other
- the other date value- Returns:
- working days between the two dates
-
workingDaysBetween
This method returns the number of full working days between this date value and another date value. Time components are ignored. The order of this date value and the other does not matter.- Parameters:
other
- the date value to compare toworkingDays
- a list with the working days, as defined bygetDayOfWeek()
method.- Returns:
- a positive integer indicating the number of full working days
-
weeksBefore
This method returns the number of weeks the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
Note that time components are ignored for both date values. For example:
new TimestampValue( 2009, 1, 1, 23, 30, 0, 0 ).weeksBefore( new DateValue(2009, 1, 8 ) ) will result in 1
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of weeks this date value is before the other date value.
-
monthsBefore
This method returns the number of months the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
Note that time components are ignored for both date values. For example:
new TimestampValue( 2009, 1, 1, 23, 30, 0, 0 ).monthsBefore( new DateValue(2009, 2, 1 ) ) will result in 1
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of months this date value is before the other date value.
-
yearsBefore
This method returns the number of years the other date value is before this.
When this date value is after the other date value, a negative integer value is returned.
When this or the other date value is unknown an unknown integer value is returned.
Note that time components are ignored for both date values. For example:
new TimestampValue( 2009, 1, 1, 23, 30, 0, 0 ).yearsBefore( new DateValue(2010, 1, 1 ) ) will result in 1
- Parameters:
other
- The DateValue to compare to, mandatory.- Returns:
- The number of years this date value is before the other date value.
-
withHours
-
withMinutes
-
withSeconds
-
withMilliseconds
-
createFor
-
withDays
-
withWeeks
-
withMonths
-
withYears
-
getDayOfWeek
- Returns:
- The day of the week, sunday (1) to saturday (7)
-
getDayOfMonth
-
getYear
-
getMonthOfYear
This method returns the month of the current date value. The number of the month ranges from 1 to 12, or unknown when the date value represents an unknown value.- Returns:
- The number of the month of the date value.
-
getWeekOfYear
This method returns the week number of the current date value. The number ranges from 1 to 53. The first day of the week is Monday and the first week of the year is the week with 4 days or more in the starting year, following the ISO 8601 Week date specification).- Returns:
- the number of the week of the year for this date value
-
toDateTimeValue
-
toDateValue
-
hourOfDay
-
minute
-
second
-
millisecond
-
now
-
duplicate
Description copied from interface:IValue
This method returns a deep copy of the value.- Specified by:
duplicate
in interfaceIValue
- Specified by:
duplicate
in classAbstractValue
- Returns:
- A deep clone.
-
finalize
protected final void finalize()
-