ca.uhn.hl7v2.model.primitive
Class CommonDT

java.lang.Object
  extended by ca.uhn.hl7v2.model.primitive.CommonDT
All Implemented Interfaces:
Serializable

public class CommonDT
extends Object
implements Serializable

This class contains functionality used by the DT class in the version 2.3.0, 2.3.1, and 2.4 packages Note: The class description below has been excerpted from the Hl7 2.4 documentation. Sectional references made below also refer to the same documentation. Format: YYYY[MM[DD]] In prior versions of HL7, this data type was always specified to be in the format YYYYMMDD. In the current and future versions, the precision of a date may be expressed by limiting the number of digits used with the format specification YYYY[MM[DD]]. Thus, YYYY is used to specify a precision of "year," YYYYMM specifies a precision of "month," and YYYYMMDD specifies a precision of "day." By site-specific agreement, YYYYMMDD may be used where backward compatibility must be maintained. Examples: |19880704| |199503|

Author:
Neal Acharya
See Also:
Serialized Form

Constructor Summary
CommonDT()
          Constructs a DT datatype with fields initialzed to zero and value initialized to null.
CommonDT(String val)
          Constructs a DT object with the given value.
 
Method Summary
 int getDay()
          Returns the day as an integer.
 int getMonth()
          Returns the month as an integer.
 String getValue()
          Returns the HL7 DT string value.
 Calendar getValueAsCalendar()
          Return the value as a calendar object
 Date getValueAsDate()
          Return the value as a date object
 int getYear()
          Returns the year as an integer.
 void setValue(Calendar theCalendar)
          Convenience setter which sets the value using a Calendar object.
 void setValue(Date theDate)
          Convenience setter which sets the value using a Date object.
 void setValue(String val)
          This method takes in a string HL7 date value and performs validations then sets the value field.
 void setYearMonthDayPrecision(int yr, int mnth, int dy)
          This method takes in integer values for the year and month and day and performs validations, it then sets the value in the object formatted as an HL7 date value with year&month&day precision (YYYYMMDD).
 void setYearMonthPrecision(int yr, int mnth)
          This method takes in integer values for the year and month and performs validations, it then sets the value field formatted as an HL7 date value with year&month precision (YYYYMM).
 void setYearPrecision(int yr)
          This method takes in an integer value for the year and performs validations, it then sets the value field formatted as an HL7 date.
static String toHl7DTFormat(GregorianCalendar cal)
          Returns a string value representing the input Gregorian Calendar object in an Hl7 Date Format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonDT

public CommonDT()
Constructs a DT datatype with fields initialzed to zero and value initialized to null.


CommonDT

public CommonDT(String val)
         throws DataTypeException
Constructs a DT object with the given value. The stored value will be in the following format YYYY[MM[DD]].

Throws:
DataTypeException
Method Detail

setValue

public void setValue(Calendar theCalendar)
              throws DataTypeException
Convenience setter which sets the value using a Calendar object. Passing in null clears any existing value. Note: Sets fields using maximum possible precision

Parameters:
theCalendar - The calendar object from which to retrieve values
Throws:
DataTypeException
Since:
1.1

setValue

public void setValue(Date theDate)
              throws DataTypeException
Convenience setter which sets the value using a Date object. Passing in null clears any existing value. Note: Sets fields using maximum possible precision

Parameters:
theCalendar - The calendar object from which to retrieve values
Throws:
DataTypeException
Since:
1.1

getValueAsCalendar

public Calendar getValueAsCalendar()
Return the value as a calendar object

Since:
1.1

getValueAsDate

public Date getValueAsDate()
Return the value as a date object

Since:
1.1

setValue

public void setValue(String val)
              throws DataTypeException
This method takes in a string HL7 date value and performs validations then sets the value field. The stored value will be in the following format YYYY[MM[DD]]. Passing in null clears any existing value.

Throws:
DataTypeException

setYearPrecision

public void setYearPrecision(int yr)
                      throws DataTypeException
This method takes in an integer value for the year and performs validations, it then sets the value field formatted as an HL7 date. value with year precision (YYYY)

Throws:
DataTypeException

setYearMonthPrecision

public void setYearMonthPrecision(int yr,
                                  int mnth)
                           throws DataTypeException
This method takes in integer values for the year and month and performs validations, it then sets the value field formatted as an HL7 date value with year&month precision (YYYYMM). Note: The first month = 1 = January.

Throws:
DataTypeException

setYearMonthDayPrecision

public void setYearMonthDayPrecision(int yr,
                                     int mnth,
                                     int dy)
                              throws DataTypeException
This method takes in integer values for the year and month and day and performs validations, it then sets the value in the object formatted as an HL7 date value with year&month&day precision (YYYYMMDD).

Throws:
DataTypeException

getValue

public String getValue()
Returns the HL7 DT string value.


getYear

public int getYear()
Returns the year as an integer.


getMonth

public int getMonth()
Returns the month as an integer.


getDay

public int getDay()
Returns the day as an integer.


toHl7DTFormat

public static String toHl7DTFormat(GregorianCalendar cal)
                            throws DataTypeException
Returns a string value representing the input Gregorian Calendar object in an Hl7 Date Format.

Throws:
DataTypeException


Copyright © 2001-2012 University Health Network. All Rights Reserved.