Class BaseDateTimeType

    • Method Detail

      • add

        public void add​(int theField,
                        int theValue)
        Adds the given amount to the field specified by theField
        Parameters:
        theField - The field, uses constants from Calendar such as Calendar.YEAR
        theValue - The number to add (or subtract for a negative number)
      • after

        public boolean after​(DateTimeType theDateTimeType)
        Returns true if the given object represents a date/time before this object
        Throws:
        NullPointerException - If this.getValue() or theDateTimeType.getValue() return null
      • before

        public boolean before​(DateTimeType theDateTimeType)
        Returns true if the given object represents a date/time before this object
        Throws:
        NullPointerException - If this.getValue() or theDateTimeType.getValue() return null
      • encode

        protected String encode​(Date theValue)
        Description copied from class: PrimitiveType
        Subclasses must override to convert a "coerced" value into an encoded one.
        Specified by:
        encode in class PrimitiveType<Date>
        Parameters:
        theValue - Will not be null
        Returns:
        May return null if the value does not correspond to anything
      • getDay

        public Integer getDay()
        Returns the month with 1-index, e.g. 1=the first day of the month
      • getDefaultPrecisionForDatatype

        protected abstract ca.uhn.fhir.model.api.TemporalPrecisionEnum getDefaultPrecisionForDatatype()
        Returns the default precision for the given datatype
      • getHour

        public Integer getHour()
        Returns the hour of the day in a 24h clock, e.g. 13=1pm
      • getMillis

        public Integer getMillis()
        Returns the milliseconds within the current second.

        Note that this method returns the same value as getNanos() but with less precision.

      • getMinute

        public Integer getMinute()
        Returns the minute of the hour in the range 0-59
      • getMonth

        public Integer getMonth()
        Returns the month with 0-index, e.g. 0=January
      • getNanos

        public Long getNanos()
        Returns the nanoseconds within the current second

        Note that this method returns the same value as getMillis() but with more precision.

      • getSecond

        public Integer getSecond()
        Returns the second of the minute in the range 0-59
      • getTimeZone

        public TimeZone getTimeZone()
        Returns the TimeZone associated with this dateTime's value. May return null if no timezone was supplied.
      • isTimeZoneZulu

        public boolean isTimeZoneZulu()
        Returns true if the timezone is set to GMT-0:00 (Z)
      • parse

        protected Date parse​(String theValue)
                      throws ca.uhn.fhir.parser.DataFormatException
        Description copied from class: PrimitiveType
        Subclasses must override to convert an encoded representation of this datatype into a "coerced" one
        Specified by:
        parse in class PrimitiveType<Date>
        Parameters:
        theValue - Will not be null
        Returns:
        May return null if the value does not correspond to anything
        Throws:
        ca.uhn.fhir.parser.DataFormatException
      • setDay

        public BaseDateTimeType setDay​(int theDay)
        Sets the month with 1-index, e.g. 1=the first day of the month
      • setMillis

        public BaseDateTimeType setMillis​(int theMillis)
        Sets the milliseconds within the current second.

        Note that this method sets the same value as setNanos(long) but with less precision.

      • setNanos

        public BaseDateTimeType setNanos​(long theNanos)
        Sets the nanoseconds within the current second

        Note that this method sets the same value as setMillis(int) but with more precision.

      • setPrecision

        public void setPrecision​(ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision)
                          throws ca.uhn.fhir.parser.DataFormatException
        Sets the precision for this datatype
        Throws:
        ca.uhn.fhir.parser.DataFormatException
      • setValue

        public BaseDateTimeType setValue​(Date theValue)
        Sets the value for this type using the given Java Date object as the time, and using the default precision for this datatype (unless the precision is already set), as well as the local timezone as determined by the local operating system. Both of these properties may be modified in subsequent calls if neccesary.
        Specified by:
        setValue in interface org.hl7.fhir.instance.model.api.IPrimitiveType<Date>
        Overrides:
        setValue in class PrimitiveType<Date>
      • setValue

        public void setValue​(Date theValue,
                             ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision)
                      throws ca.uhn.fhir.parser.DataFormatException
        Sets the value for this type using the given Java Date object as the time, and using the specified precision, as well as the local timezone as determined by the local operating system. Both of these properties may be modified in subsequent calls if neccesary.
        Parameters:
        theValue - The date value
        thePrecision - The precision
        Throws:
        ca.uhn.fhir.parser.DataFormatException
      • setValueAsString

        public void setValueAsString​(String theValue)
                              throws ca.uhn.fhir.parser.DataFormatException
        Specified by:
        setValueAsString in interface org.hl7.fhir.instance.model.api.IPrimitiveType<Date>
        Overrides:
        setValueAsString in class PrimitiveType<Date>
        Throws:
        ca.uhn.fhir.parser.DataFormatException
      • toCalendar

        public Calendar toCalendar()
        Returns a view of this date/time as a Calendar object. Note that the returned Calendar object is entirely independent from this object. Changes to the calendar will not affect this.
      • toHumanDisplay

        public String toHumanDisplay()
        Returns a human readable version of this date/time using the system local format.

        Note on time zones: This method renders the value using the time zone that is contained within the value. For example, if this date object contains the value "2012-01-05T12:00:00-08:00", the human display will be rendered as "12:00:00" even if the application is being executed on a system in a different time zone. If this behaviour is not what you want, use toHumanDisplayLocalTimezone() instead.