Class Timestamp
- java.lang.Object
-
- org.openehealth.ipf.commons.ihe.xds.core.metadata.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Timestamp.Precision
-
Constructor Summary
Constructors Constructor Description Timestamp()
Timestamp(ZonedDateTime dateTime, Timestamp.Precision precision)
Initializes aTimestamp
object with the given datetime and precision.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Two HL7 timestamps are equal when they have the same values in the relevant fields (i.e.static Timestamp
fromHL7(String s)
Creates aTimestamp
object from the given string.ZonedDateTime
getDateTime()
Timestamp.Timestamp.Precision
getPrecision()
int
hashCode()
static Timestamp
now()
void
setDateTime(ZonedDateTime dateTime)
void
setPrecision(Timestamp.Precision precision)
Precision of the timestamp (smallest present element, e.g.String
toHL7()
static String
toHL7(Timestamp timestamp)
Returns a HL7 representation of the given timestamp, considering the precision.String
toString()
-
-
-
Constructor Detail
-
Timestamp
public Timestamp()
-
Timestamp
public Timestamp(ZonedDateTime dateTime, Timestamp.Precision precision)
Initializes aTimestamp
object with the given datetime and precision.
-
-
Method Detail
-
fromHL7
public static Timestamp fromHL7(String s)
Creates aTimestamp
object from the given string.- Parameters:
s
- String of the patternYYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]
. Milliseconds will be ignored.- Returns:
- a
Timestamp
object, ornull
if the parameter isnull
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 benull
.- Returns:
- HL7 representation of the timestamp, or
null
if the parameter isnull
.
-
toHL7
public String toHL7()
-
setDateTime
public void setDateTime(ZonedDateTime dateTime)
-
getPrecision
public Timestamp.Precision getPrecision()
-
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).
-
getDateTime
public ZonedDateTime getDateTime()
Timestamp.
-
setPrecision
public void setPrecision(Timestamp.Precision precision)
Precision of the timestamp (smallest present element, e.g. YEAR for "1980").
-
-