Class DateTimeValue

All Implemented Interfaces:
IConvertable, IPrimitiveValue, ISingleValue, IValue, Serializable, Comparable<Object>
Direct Known Subclasses:
AttributeDateTimeValue

public class DateTimeValue extends DateValue
This primitive class holds the information about a single datetime value.
Since:
7.1
Author:
Jon van Leuven
See Also:
  • Field Details

    • UNKNOWN

      public static final DateTimeValue UNKNOWN
      This member defines the UNKNOWN value for the datetime type.
  • Constructor Details

    • DateTimeValue

      public DateTimeValue(DateValue other)
      Copy constructor.
      Parameters:
      other - DateValue to copy.
    • DateTimeValue

      public DateTimeValue(int year, int month, int day, int hour, int minute, int second, int millis)
      Construct a DateTimeValue, with year months, day, hour, minute, second.
      • 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:
      year - The year of the date (1 through 9999).
      month - The month of the date (a value from 1 up to 12).
      day - The day of the date (a value from 1 up to the number of days in m).
      hour - The hour of the date (a value from 0 up 23).
      minute - The minute of the date (a value from 0 up 59).
      second - The second of the date (a value from 0 up 59).
      millis - The millisecond of the date (a value from 0 up 999).
    • DateTimeValue

      public DateTimeValue(int year, int month, int day)
      Construct a DateTimeValue, with year months and day at midnight
      • 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:
      year - The year of the date (1 through 9999).
      month - The month of the date (a value from 1 up to 12).
      day - The day of the date (a value from 1 up to the number of days in m).
    • DateTimeValue

      public DateTimeValue(ZonedDateTime zdt)
      Construct a DateTimeValue 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.
      Since:
      17.0
    • DateTimeValue

      public DateTimeValue(Date date)
      Construct a DateTimeValue 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, may be null.
    • DateTimeValue

      public DateTimeValue(IMultilingualText displayValue, Date date)
      Construct a DateTimeValue based on a Date 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, may be null.
    • DateTimeValue

      public DateTimeValue(String typeName, IMultilingualText displayValue, Date date)
      Construct a DateTimeValue 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, may be null.
  • Method Details

    • valueOf

      public static DateTimeValue valueOf(Object obj)
      Parse an object and returns its DateTimeValue.
      • Date/time Strings are always interpreted using the (proleptic) Gregorian calendar rules. Before 17.0, date/time Strings before 1582-10-15 where interpreted using the Julian calendar rules
      • Date/time Strings are interpreted using the system default timezone
      Parameters:
      obj - The object to parse.
      Returns:
      The DateTimeValue representation of the object, never null, but can be unknown.
      Throws:
      ConversionException - Is thrown when parsing fails.
    • parseDateTime

      public static Date parseDateTime(Object obj)
      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 date and time component. If the String contains only the date without time, it cannot be parsed. Use DateValue.valueOf(Object) instead.
      • Date/time Strings are always interpreted using the (proleptic) Gregorian calendar rules. Before 17.0, date/time Strings before 1582-10-15 where interpreted using the Julian calendar rules
      • Date/time Strings are interpreted using the system default timezone
      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.
    • createNow

      public static DateTimeValue createNow()
      This method can be used to create a DateTimeValue for the current time. The current time is included in the resulting date time value.
      Returns:
      DateTimeValue for now.
    • forType

      public IPrimitiveValue forType(String typeName, IMultilingualText displayValue)
      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 interface IPrimitiveValue
      Overrides:
      forType in class DateValue
      Parameters:
      typeName - The type of the value.
      displayValue - Multilingual text containing display values.
      Returns:
      The value with the added information.
    • getDataType

      public DataType getDataType()
      Description copied from interface: IValue
      This method returns the data type of the value.
      Specified by:
      getDataType in interface IValue
      Overrides:
      getDataType in class DateValue
      Returns:
      The data type of the value.
    • toString

      public String toString()
      Overrides:
      toString in class DateValue
    • stringValue

      public String stringValue()
      Format this DateTimeValue to a String in the 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.
      Specified by:
      stringValue in interface IConvertable
      Overrides:
      stringValue in class DateValue
      Returns:
      A String representation of this DateTimeValue
    • getHour

      public IntegerValue getHour()
    • getMinute

      public IntegerValue getMinute()
    • getSecond

      public IntegerValue getSecond()
    • getMillisecond

      public IntegerValue getMillisecond()
    • duplicate

      public IValue duplicate()
      Description copied from interface: IValue
      This method returns a deep copy of the value.
      Specified by:
      duplicate in interface IValue
      Overrides:
      duplicate in class DateValue
      Returns:
      A deep clone.