Wiki

Clone wiki

itk-payloads / pages / Dates

Dates and Times

The HL7v3 standard allows for dates and times to be represented at varying levels of precision. For this reason, the itk-payloads library can’t use a java.util.Date object directly, and provides a DateValue class to represent HL7v3 dates.

There are two main ways a date/time can be created:

1) Using a string value that conforms with the format defined by HL7:

DateValue date1 = new DateValue("20121127151500+0000");

2) Using a java.util.Date along with a DatePrecision value:

DateValue date2 = new DateValue(new Date(), DatePrecision.Minutes);

The possible values for DatePrecision are listed in the DatePrecision enumeration

When dates are parsed from a received document you can use the getDate() method to get a java.util.Date object, or the getDisplayString() method to get a version of the date formatted for display. The precision can also be ascertained by calling getPrecision().

Updated