Class Timestamp

  • All Implemented Interfaces:
    Serializable

    public class Timestamp
    extends Object
    implements Serializable
    HL7 timestamps (data type DTM) with particular precision, normalized to UTC.
    Author:
    Dmytro Rud
    See Also:
    Serialized Form
    • Method Detail

      • fromHL7

        public static Timestamp fromHL7​(String s)
        Creates a Timestamp object from the given string.
        Parameters:
        s - String of the pattern YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]. Milliseconds will be ignored.
        Returns:
        a Timestamp object, or null if the parameter is null or empty.
      • toHL7

        public static String toHL7​(Timestamp timestamp)
        Returns a HL7 representation of the given timestamp, considering the precision.
        Parameters:
        timestamp - Timestamp object, can be null.
        Returns:
        HL7 representation of the timestamp, or null if the parameter is null.
      • toHL7

        public String toHL7()
      • setDateTime

        public void setDateTime​(ZonedDateTime dateTime)
      • now

        public static Timestamp now()
        Returns:
        a Timestamp with the current date-time in second precision.
      • equals

        public boolean equals​(Object o)
        Two HL7 timestamps are equal when they have the same values in the relevant fields (i.e. in the ones covered by the precision).
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • setPrecision

        public void setPrecision​(Timestamp.Precision precision)
        Precision of the timestamp (smallest present element, e.g. YEAR for "1980").