Package ca.uhn.hl7v2.model.primitive
Class CommonDT
java.lang.Object
ca.uhn.hl7v2.model.primitive.CommonDT
- All Implemented Interfaces:
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetDay()Returns the day as an integer.intgetMonth()Returns the month as an integer.getValue()Returns the HL7 DT string value.Return the value as a calendar objectReturn the value as a date objectintgetYear()Returns the year as an integer.voidThis method takes in a string HL7 date value and performs validations then sets the value field.voidConvenience setter which sets the value using aCalendarobject.voidConvenience setter which sets the value using aDateobject.voidsetYearMonthDayPrecision(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).voidsetYearMonthPrecision(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).voidsetYearPrecision(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 StringReturns a string value representing the input Gregorian Calendar object in an Hl7 Date Format.
-
Constructor Details
-
CommonDT
public CommonDT()Constructs a DT datatype with fields initialzed to zero and value initialized to null. -
CommonDT
Constructs a DT object with the given value. The stored value will be in the following format YYYY[MM[DD]].- Throws:
DataTypeException
-
-
Method Details
-
setValue
Convenience setter which sets the value using aCalendarobject. Passing innullclears 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
Convenience setter which sets the value using aDateobject. Passing innullclears any existing value. Note: Sets fields using maximum possible precision- Parameters:
theDate- The date object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
getValueAsCalendar
Return the value as a calendar object- Since:
- 1.1
-
getValueAsDate
Return the value as a date object- Since:
- 1.1
-
setValue
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 innullclears any existing value.- Throws:
DataTypeException
-
setYearPrecision
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
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
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
Returns the HL7 DT string value. -
getYear
Returns the year as an integer. -
getMonth
Returns the month as an integer. -
getDay
Returns the day as an integer. -
toHl7DTFormat
Returns a string value representing the input Gregorian Calendar object in an Hl7 Date Format.- Throws:
DataTypeException
-