org.urhl7.utils
Class Convert

java.lang.Object
  extended by org.urhl7.utils.Convert

public class Convert
extends Object

A utility class that allows for conversion between various data types. Generally DataField/String data types and more usable Object representations such as Date.


Field Summary
static int PRECISION_DAY
          Precision size to create an HL7 date/time to the day
static int PRECISION_HOURS
          Precision size to create an HL7 date/time to hours
static int PRECISION_MINUTES
          Precision size to create an HL7 date/time to minutes
static int PRECISION_SECONDS
          Precision size to create an HL7 date/time to seconds
 
Method Summary
static Date toDate(DataField dateDataField)
          Creates a Date object from an DataField that is representing a date/time in the standard HL7 format.
static Date toDate(String hl7DateString)
          Creates a Date object from a String that follows the HL7 date/time format (yyyyMMddHHmmss).
static String toHL7String(Date date)
          Creates a String that represents the specified Date object in the HL7 date/time format.
static String toHL7String(Date date, int precision)
          Creates a String that represents the specified Date object in the HL7 date/time format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRECISION_SECONDS

public static final int PRECISION_SECONDS
Precision size to create an HL7 date/time to seconds

See Also:
Constant Field Values

PRECISION_MINUTES

public static final int PRECISION_MINUTES
Precision size to create an HL7 date/time to minutes

See Also:
Constant Field Values

PRECISION_HOURS

public static final int PRECISION_HOURS
Precision size to create an HL7 date/time to hours

See Also:
Constant Field Values

PRECISION_DAY

public static final int PRECISION_DAY
Precision size to create an HL7 date/time to the day

See Also:
Constant Field Values
Method Detail

toDate

public static Date toDate(DataField dateDataField)
Creates a Date object from an DataField that is representing a date/time in the standard HL7 format. Precision is up to seconds.

Parameters:
dateDataField - the DateField representation of an HL7 date/time
Returns:
a Date object instantiated with the specified time

toDate

public static Date toDate(String hl7DateString)
Creates a Date object from a String that follows the HL7 date/time format (yyyyMMddHHmmss). Precision is up to seconds.

Parameters:
hl7DateString - a String representing an HL7 date/time
Returns:
a Date object instantiated with the specified time

toHL7String

public static String toHL7String(Date date)
Creates a String that represents the specified Date object in the HL7 date/time format. The default precision is to seconds.

Parameters:
date - a Date object to represent
Returns:
a formatted String of provided Date object

toHL7String

public static String toHL7String(Date date,
                                 int precision)
Creates a String that represents the specified Date object in the HL7 date/time format.

Parameters:
date - a Date object to represent
precision - the precision to create the string. Convert.PRECISION_SECONDS or Convert.PRECISION_MINUTES are most common
Returns:
a formatted String of provided Date object