Class CommonTM

java.lang.Object
ca.uhn.hl7v2.model.primitive.CommonTM
All Implemented Interfaces:
Serializable

public class CommonTM extends Object implements 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 Details

  • Constructor Details

    • CommonTM

      public CommonTM()
      Constructs a TM datatype with fields initialzed to zero and the value set to null.
    • CommonTM

      public CommonTM(String val) throws DataTypeException
      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

      public void setValue(String val) throws DataTypeException
      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 in null clears any existing value.
      Throws:
      DataTypeException
    • setHourPrecision

      public void setHourPrecision(int hr) throws DataTypeException
      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

      public void setHourMinutePrecision(int hr, int min) throws DataTypeException
      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

      public void setHourMinSecondPrecision(int hr, int min, float sec) throws DataTypeException
      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

      public void setOffset(int signedOffset) throws DataTypeException
      This method takes in the four digit (signed) GMT offset and sets the offset field
      Throws:
      DataTypeException
    • getValue

      public String getValue()
      Returns the HL7 TM string value.
    • setValueToMinute

      public void setValueToMinute(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 precision up to the minute
      Parameters:
      theCalendar - The calendar object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • setValueToMinute

      public void setValueToMinute(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 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

      public void setValueToSecond(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 precision up to the second
      Parameters:
      theCalendar - The calendar object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • 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 precision up to the millisecond, including timezone offset
      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 Calendar object. Passing in null clears 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

      public void setValueToSecond(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 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

      public Date 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

      public int getHour()
      Returns the hour as an integer.
    • getMinute

      public int getMinute()
      Returns the minute as an integer.
    • getSecond

      public int getSecond()
      Returns the second as an integer.
    • getFractSecond

      public float getFractSecond()
      Returns the fractional second value as a float.
    • getGMTOffset

      public int getGMTOffset()
      Returns the GMT offset value as an integer, GMT_OFFSET_NOT_SET_VALUE if not set.
    • toHl7TMFormat

      Returns a string value representing the input Gregorian Calendar object in an Hl7 Time Format.
      Throws:
      DataTypeException