Package ca.uhn.hl7v2.model.primitive
Class CommonTM
java.lang.Object
ca.uhn.hl7v2.model.primitive.CommonTM
- All Implemented Interfaces:
Serializable
This class contains functionality used by the TM 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: HH[MM[SS[.S[S[S[S]]]]]][+/-ZZZZ]
In prior versions of HL7, this data type was always specified to be in the
format HHMM[SS[.SSSS]][+/-ZZZZ] using a 24 hour clock notation. In the
current and future versions, the precision of a time may be expressed by
limiting the number of digits used with the format specification as shown
above. By site-specific agreement, HHMM[SS[.SSSS]][+/-ZZZZ] may be used where
backward compatibility must be maintained.
Thus, HH is used to specify a precision of "hour," HHMM is used to specify a
precision of "minute," HHMMSS is used to specify a precision of seconds, and
HHMMSS.SSSS is used to specify a precision of ten-thousandths of a second.
In each of these cases, the time zone is an optional component. The fractional
seconds could be sent by a transmitter who requires greater precision than whole
seconds. Fractional representations of minutes, hours or other higher-order units
of time are not permitted.
Note: The time zone [+/-ZZZZ], when used, is restricted to legally-defined time zones
and is represented in HHMM format.
The time zone of the sender may be sent optionally as an offset from the coordinated
universal time (previously known as Greenwich Mean Time). Where the time zone
is not present in a particular TM field but is included as part of the date/time
field in the MSH segment, the MSH value will be used as the default time zone.
Otherwise, the time is understood to refer to the local time of the sender.
Midnight is represented as 0000.
Examples:|235959+1100| 1 second before midnight in a time zone eleven hours
ahead of Universal Coordinated Time (i.e., east of Greenwich).
|0800| Eight AM, local time of the sender.
|093544.2312| 44.2312 seconds after Nine thirty-five AM, local time of sender.
|13| 1pm (with a precision of hours), local time of sender.
- Author:
- Neal Acharya
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intValue returned bygetGMTOffset()if no offset is set -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatReturns the fractional second value as a float.intReturns the GMT offset value as an integer,GMT_OFFSET_NOT_SET_VALUEif not set.intgetHour()Returns the hour as an integer.intReturns the minute as an integer.intReturns the second as an integer.getValue()Returns the HL7 TM string value.Return the value as a calendar object.Return the value as a date objectvoidsetHourMinSecondPrecision(int hr, int min, float sec) This method takes in integer values for the hour, minute, seconds, and fractional seconds (going to the tenthousandths precision).voidsetHourMinutePrecision(int hr, int min) This method takes in integer values for the hour and minute and performs validations, it then sets the value field formatted as an HL7 time value with hour&minute precision (HHMM).voidsetHourPrecision(int hr) This method takes in an integer value for the hour and performs validations, it then sets the value field formatted as an HL7 time value with hour precision (HH).voidsetOffset(int signedOffset) This method takes in the four digit (signed) GMT offset and sets the offset fieldvoidThis method takes in a string HL7 Time value and performs validations then sets the value field.voidConvenience setter which sets the value using aCalendarobject.voidConvenience setter which sets the value using aCalendarobject.voidsetValueToMinute(Calendar theCalendar) Convenience setter which sets the value using aCalendarobject.voidsetValueToMinute(Date theDate) Convenience setter which sets the value using aDateobject.voidsetValueToSecond(Calendar theCalendar) Convenience setter which sets the value using aCalendarobject.voidsetValueToSecond(Date theDate) Convenience setter which sets the value using aDateobject.static StringReturns a string value representing the input Gregorian Calendar object in an Hl7 Time Format.
-
Field Details
-
GMT_OFFSET_NOT_SET_VALUE
Value returned bygetGMTOffset()if no offset is set- See Also:
-
-
Constructor Details
-
CommonTM
public CommonTM()Constructs a TM datatype with fields initialzed to zero and the value set to null. -
CommonTM
Constructs a TM object with the given value. The stored value will be in the following format HH[MM[SS[.S[S[S[S]]]]]][+/-ZZZZ].- Throws:
DataTypeException
-
-
Method Details
-
setValue
This method takes in a string HL7 Time value and performs validations then sets the value field. The stored value will be in the following format HH[MM[SS[.S[S[S[S]]]]]][+/-ZZZZ]. Note: Trailing zeros supplied in the time value (HH[MM[SS[.S[S[S[S]]]]]]) and GMT offset ([+/-ZZZZ]) will be preserved. Note: If the GMT offset is not supplied then the local time zone (using standard time zone format which is not modified for daylight savings) will be stored as a default. Passing innullclears any existing value.- Throws:
DataTypeException
-
setHourPrecision
This method takes in an integer value for the hour and performs validations, it then sets the value field formatted as an HL7 time value with hour precision (HH).- Throws:
DataTypeException
-
setHourMinutePrecision
This method takes in integer values for the hour and minute and performs validations, it then sets the value field formatted as an HL7 time value with hour&minute precision (HHMM).- Throws:
DataTypeException
-
setHourMinSecondPrecision
This method takes in integer values for the hour, minute, seconds, and fractional seconds (going to the tenthousandths precision). The method performs validations and then sets the value field formatted as an HL7 time value with a precision that starts from the hour and goes down to the tenthousandths of a second (HHMMSS.SSSS). Note: all of the precisions from tenths down to tenthousandths of a second are optional. If the precision goes below tenthousandths of a second then the second value will be rounded to the nearest tenthousandths of a second.- Throws:
DataTypeException
-
setOffset
This method takes in the four digit (signed) GMT offset and sets the offset field- Throws:
DataTypeException
-
getValue
Returns the HL7 TM string value. -
setValueToMinute
Convenience setter which sets the value using aCalendarobject. Passing innullclears any existing value. Note: Sets fields using precision up to the minute- Parameters:
theCalendar- The calendar object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
setValueToMinute
Convenience setter which sets the value using aDateobject. Passing innullclears any existing value. Note: Sets fields using precision up to the minute Note: Date is timezone-agnostic, representing always GMT time- Parameters:
theDate- The date object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
setValueToSecond
Convenience setter which sets the value using aCalendarobject. Passing innullclears any existing value. Note: Sets fields using precision up to the second- Parameters:
theCalendar- The calendar object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
setValue
Convenience setter which sets the value using aCalendarobject. Passing innullclears any existing value. Note: Sets fields using precision up to the millisecond, including timezone offset- Parameters:
theCalendar- The calendar object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
setValue
Convenience setter which sets the value using aCalendarobject. Passing innullclears any existing value. Note: Sets fields using precision up to the millisecond, and sets the timezone offset to the current system offset Note: Date is timezone-agnostic, representing always GMT time- Parameters:
theDate- The calendar object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
setValueToSecond
Convenience setter which sets the value using aDateobject. Passing innullclears any existing value. Note: Sets fields using precision up to the second Note: Date is timezone-agnostic, representing always GMT time- Parameters:
theDate- The date object from which to retrieve values- Throws:
DataTypeException- Since:
- 1.1
-
getValueAsCalendar
Return the value as a calendar object.
Note that only the time component of the return value is set to the value from this object. Returned value will have today's date- Since:
- 1.1
-
getValueAsDate
Return the value as a date object
Note that only the time component of the return value is set to the value from this object. Returned value will have today's date Note: Date is timezone-agnostic, representing always GMT time- Since:
- 1.1
-
getHour
Returns the hour as an integer. -
getMinute
Returns the minute as an integer. -
getSecond
Returns the second as an integer. -
getFractSecond
Returns the fractional second value as a float. -
getGMTOffset
Returns the GMT offset value as an integer,GMT_OFFSET_NOT_SET_VALUEif not set. -
toHl7TMFormat
Returns a string value representing the input Gregorian Calendar object in an Hl7 Time Format.- Throws:
DataTypeException
-