Class Hl7Dtm

java.lang.Object
org.projecthusky.common.utils.time.Hl7Dtm

public class Hl7Dtm extends Object
HL7 timestamps (data type DTM) with particular precision, normalized to UTC.

Original code from IPF (https://github.com/oehf/ipf) under Apache 2.0 licence.

Author:
Dmytro Rud
  • Constructor Details

  • Method Details

    • fromHl7

      public static Hl7Dtm fromHl7(@NonNull String s)
      Creates a Hl7Dtm 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 Hl7Dtm object.
      Throws:
      IllegalArgumentException - if the DTM string is invalid.
    • now

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

      public static OffsetDateTime toOffsetDateTime(@NonNull String s)
      Creates a OffsetDateTime 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 OffsetDateTime object, or null if the parameter is null or empty.
      Throws:
      IllegalArgumentException - if the DTM string is invalid.
    • setDateTime

      public void setDateTime(@NonNull OffsetDateTime dateTime)
    • getDateTime

      public @NonNull OffsetDateTime getDateTime()
    • setPrecision

      public void setPrecision(@NonNull Hl7Dtm.Precision precision)
    • getPrecision

      public @NonNull Hl7Dtm.Precision getPrecision()
    • toInstant

      public @NonNull Instant toInstant()
    • toHl7

      public @NonNull String toHl7()
    • equals

      public boolean equals(@Nullable 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
    • toString

      public String toString()
      Overrides:
      toString in class Object