java.lang.Object
java.lang.Record
org.eclipse.milo.opcua.stack.core.types.builtin.DateTime

public record DateTime(long utcTime) extends Record
  • Field Details

    • MIN_ISO_8601_STRING

      public static final String MIN_ISO_8601_STRING
      Minimum ISO-8601 formatted string.
      See Also:
    • MAX_ISO_8601_STRING

      public static final String MAX_ISO_8601_STRING
      Maximum ISO-8601 formatted string.
      See Also:
    • MIN_ISO_8601_INSTANT

      public static final Instant MIN_ISO_8601_INSTANT
      Minimum Instant that can be formatted in ISO-8601, i.e. "0001-01-01T00:00:00Z".
    • MAX_ISO_8601_INSTANT

      public static final Instant MAX_ISO_8601_INSTANT
      Minimum Instant that can be formatted in ISO-8601, i.e. "0001-01-01T00:00:00Z".
    • MIN_DATE_TIME

      public static final DateTime MIN_DATE_TIME
      Minimum DateTime that can be represented on this "DevelopmentPlatform".
    • MAX_DATE_TIME

      public static final DateTime MAX_DATE_TIME
      Maximum DateTime that can be represented on this "DevelopmentPlatform".
    • USE_NANOS

      public static volatile boolean USE_NANOS
      When true, now() will use nanosecond precision.
    • MIN_VALUE

      public static final DateTime MIN_VALUE
    • NULL_VALUE

      public static final DateTime NULL_VALUE
  • Constructor Details

    • DateTime

      public DateTime()
    • DateTime

      public DateTime(Date date)
    • DateTime

      public DateTime(Instant instant)
    • DateTime

      public DateTime(long utcTime)
      Creates an instance of a DateTime record class.
      Parameters:
      utcTime - the value for the utcTime record component
  • Method Details

    • getUtcTime

      public long getUtcTime()
      Returns:
      this time as 100 nanosecond intervals since UTC epoch.
    • getJavaTime

      public long getJavaTime()
      Returns:
      this time as milliseconds since Java epoch.
    • getJavaDate

      public Date getJavaDate()
      Returns:
      this time as a Date.
    • getJavaInstant

      public Instant getJavaInstant()
      Returns:
      this time as an Instant.
    • isValid

      public boolean isValid()
    • isInvalid

      public boolean isInvalid()
    • isNull

      public boolean isNull()
      Check if this is a "null" DateTime.

      A "null" DateTime has a `utcTime` of 0, i.e. it is equivalent to the ISO-8601 date "1601-01-01T00:00:00Z".

      Returns:
      true if this DateTime is "null", false otherwise.
    • isNotNull

      public boolean isNotNull()
      Check if this is not a "null" DateTime.
      Returns:
      true if this DateTime is not "null", false otherwise.
    • toIso8601String

      public String toIso8601String()
    • equals

      public boolean equals(Object o)
      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 with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • now

      public static DateTime now()
      Get a DateTime initialized to now.

      The precision depends on the value of USE_NANOS.

      Returns:
      a DateTime initialized to now.
    • nowMillis

      public static DateTime nowMillis()
      Returns:
      a DateTime initialized to now with millisecond precision.
    • nowNanos

      public static DateTime nowNanos()
      Returns:
      a DateTime initialized to now with nanosecond precision.
    • utcTime

      public long utcTime()
      Returns the value of the utcTime record component.
      Returns:
      the value of the utcTime record component