ca.uhn.hl7v2.model.primitive
Class CommonDT

java.lang.Object
  extended by ca.uhn.hl7v2.model.primitive.CommonDT

public class CommonDT
extends java.lang.Object

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

Constructor Summary
CommonDT()
          Constructs a DT datatype with fields initialzed to zero and value initialized to null.
CommonDT(java.lang.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.
 java.lang.String getValue()
          Returns the HL7 DT string value.
 int getYear()
          Returns the year as an integer.
 void setValue(java.lang.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 java.lang.String toHl7DTFormat(java.util.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(java.lang.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(java.lang.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]].

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 java.lang.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 java.lang.String toHl7DTFormat(java.util.GregorianCalendar cal)
                                      throws DataTypeException
Returns a string value representing the input Gregorian Calendar object in an Hl7 Date Format.

Throws:
DataTypeException


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