Class BaseDateTimeType
- All Implemented Interfaces:
ca.uhn.fhir.model.api.IElement,Externalizable,Serializable,org.hl7.fhir.instance.model.api.IBase,org.hl7.fhir.instance.model.api.IBaseDatatype,org.hl7.fhir.instance.model.api.IBaseElement,org.hl7.fhir.instance.model.api.IBaseHasExtensions,org.hl7.fhir.instance.model.api.IPrimitiveType<Date>
- Direct Known Subclasses:
DateTimeType,DateType,InstantType
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorBaseDateTimeType(String theString) ConstructorBaseDateTimeType(Date theDate, ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision) ConstructorBaseDateTimeType(Date theDate, ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision, TimeZone theTimeZone) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int theField, int theValue) Adds the given amount to the field specified by theFieldbooleanafter(DateTimeType theDateTimeType) Returnstrueif the given object represents a date/time beforethisobjectbooleanbefore(DateTimeType theDateTimeType) Returnstrueif the given object represents a date/time beforethisobjectstatic IntegercompareTimes(BaseDateTimeType left, BaseDateTimeType right, Integer def) protected StringSubclasses must override to convert a "coerced" value into an encoded one.equalsUsingFhirPathRules(BaseDateTimeType theOther) This method implements a datetime equality check using the rules as defined by FHIRPath (R2) Caveat: this implementation assumes local timezone for unspecified timezonesfpValue()getDay()Returns the month with 1-index, e.g.protected abstract ca.uhn.fhir.model.api.TemporalPrecisionEnumReturns the default precision for the given datatypegetHour()Returns the hour of the day in a 24h clock, e.g.Returns the milliseconds within the current second.Returns the minute of the hour in the range 0-59getMonth()Returns the month with 0-index, e.g.getNanos()Returns the nanoseconds within the current secondca.uhn.fhir.model.api.TemporalPrecisionEnumGets the precision for this datatype (using the default for the given type if not set)Returns the second of the minute in the range 0-59floatReturns the TimeZone associated with this dateTime's value.Returns the value of this object as aGregorianCalendargetYear()Returns the year, e.g.booleanhasTime()booleanbooleanReturns true if the timezone is set to GMT-0:00 (Z)booleanisToday()Returnstrueif this object represents a date that is today's dateprotected DateSubclasses must override to convert an encoded representation of this datatype into a "coerced" onesetDay(int theDay) Sets the month with 1-index, e.g.setHour(int theHour) Sets the hour of the day in a 24h clock, e.g.setMillis(int theMillis) Sets the milliseconds within the current second.setMinute(int theMinute) Sets the minute of the hour in the range 0-59setMonth(int theMonth) Sets the month with 0-index, e.g.setNanos(long theNanos) Sets the nanoseconds within the current secondvoidsetPrecision(ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision) Sets the precision for this datatypesetSecond(int theSecond) Sets the second of the minute in the range 0-59setTimeZone(TimeZone theTimeZone) setTimeZoneZulu(boolean theTimeZoneZulu) 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.voidSets 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.voidsetValueAsString(String theValue) protected voidsetValueAsV3String(String theV3String) setYear(int theYear) Sets the year, e.g.Returns a view of this date/time as a Calendar object.Returns a human readable version of this date/time using the system local format.Returns a human readable version of this date/time using the system local format, converted to the local timezone if neccesary.Methods inherited from class org.hl7.fhir.r5.model.PrimitiveType
asStringValue, copy, equalsDeep, equalsShallow, forceStringValue, fromStringValue, getProperty, getTypesForProperty, getValue, getValueAsString, hashCode, hasPrimitiveValue, hasValue, isEmpty, isPrimitive, makeProperty, primitiveValue, readExternal, setProperty, setProperty, toString, typedCopy, updateStringValue, writeExternalMethods inherited from class org.hl7.fhir.r5.model.DataType
copyValues, fhirTypeMethods inherited from class org.hl7.fhir.r5.model.Element
addChild, addExtension, addExtension, addExtension, copyValues, getExtension, getExtensionByUrl, getExtensionFirstRep, getExtensionsByUrl, getExtensionString, getId, getIdBase, getIdElement, getNamedProperty, hasExtension, hasExtension, hasId, hasIdElement, isDisallowExtensions, listChildren, noExtensions, removeExtension, setDisallowExtensions, setExtension, setId, setIdBase, setIdElementMethods inherited from class org.hl7.fhir.r5.model.Base
children, clearUserData, compareDeep, compareDeep, compareDeep, compareDeep, compareValues, compareValues, copyUserData, copyValues, equals, getChildByName, getFormatCommentsPost, getFormatCommentsPre, getNamedProperty, getUserData, getUserInt, getUserString, getXhtml, hasFormatComment, hasType, hasUserData, isBooleanPrimitive, isMetadataBased, isResource, listChildrenByName, listChildrenByName, setUserData, setUserDataINNMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hl7.fhir.instance.model.api.IBase
fhirType, getFormatCommentsPost, getFormatCommentsPre, getUserData, hasFormatComment, setUserDataMethods inherited from interface org.hl7.fhir.instance.model.api.IBaseElement
getUserData, setUserDataMethods inherited from interface org.hl7.fhir.instance.model.api.IBaseHasExtensions
addExtension, getExtension, hasExtension
-
Constructor Details
-
BaseDateTimeType
public BaseDateTimeType()Constructor -
BaseDateTimeType
Constructor- Throws:
IllegalArgumentException- If the specified precision is not allowed for this type
-
BaseDateTimeType
public BaseDateTimeType(Date theDate, ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision, TimeZone theTimeZone) Constructor -
BaseDateTimeType
Constructor- Throws:
IllegalArgumentException- If the specified precision is not allowed for this type
-
-
Method Details
-
add
Adds the given amount to the field specified by theField- Parameters:
theField- The field, uses constants fromCalendarsuch asCalendar.YEARtheValue- The number to add (or subtract for a negative number)
-
after
Returnstrueif the given object represents a date/time beforethisobject- Throws:
NullPointerException- Ifthis.getValue()ortheDateTimeType.getValue()returnnull
-
before
Returnstrueif the given object represents a date/time beforethisobject- Throws:
NullPointerException- Ifthis.getValue()ortheDateTimeType.getValue()returnnull
-
encode
Description copied from class:PrimitiveTypeSubclasses must override to convert a "coerced" value into an encoded one.- Specified by:
encodein classPrimitiveType<Date>- Parameters:
theValue- Will not be null- Returns:
- May return null if the value does not correspond to anything
-
getDay
Returns the month with 1-index, e.g. 1=the first day of the month -
getDefaultPrecisionForDatatype
Returns the default precision for the given datatype -
getHour
Returns the hour of the day in a 24h clock, e.g. 13=1pm -
getMillis
Returns the milliseconds within the current second.Note that this method returns the same value as
getNanos()but with less precision. -
getMinute
Returns the minute of the hour in the range 0-59 -
getMonth
Returns the month with 0-index, e.g. 0=January -
getSecondsMilli
-
getNanos
Returns the nanoseconds within the current secondNote that this method returns the same value as
getMillis()but with more precision. -
getPrecision
Gets the precision for this datatype (using the default for the given type if not set)- See Also:
-
getSecond
Returns the second of the minute in the range 0-59 -
getTimeZone
Returns the TimeZone associated with this dateTime's value. May returnnullif no timezone was supplied. -
getValueAsCalendar
Returns the value of this object as aGregorianCalendar -
getYear
Returns the year, e.g. 2015 -
isTimeZoneZulu
Returns true if the timezone is set to GMT-0:00 (Z) -
isToday
Returnstrueif this object represents a date that is today's date- Throws:
NullPointerException- ifPrimitiveType.getValue()returnsnull
-
parse
Description copied from class:PrimitiveTypeSubclasses must override to convert an encoded representation of this datatype into a "coerced" one- Specified by:
parsein classPrimitiveType<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
Sets the month with 1-index, e.g. 1=the first day of the month -
setHour
Sets the hour of the day in a 24h clock, e.g. 13=1pm -
setMillis
Sets the milliseconds within the current second.Note that this method sets the same value as
setNanos(long)but with less precision. -
setMinute
Sets the minute of the hour in the range 0-59 -
setMonth
Sets the month with 0-index, e.g. 0=January -
setNanos
Sets the nanoseconds within the current secondNote 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
-
setSecond
Sets the second of the minute in the range 0-59 -
setTimeZone
-
setTimeZoneZulu
-
setValue
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:
setValuein interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<Date>- Overrides:
setValuein classPrimitiveType<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 valuethePrecision- The precision- Throws:
ca.uhn.fhir.parser.DataFormatException
-
setValueAsString
- Specified by:
setValueAsStringin interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<Date>- Overrides:
setValueAsStringin classPrimitiveType<Date>- Throws:
ca.uhn.fhir.parser.DataFormatException
-
setValueAsV3String
-
setYear
Sets the year, e.g. 2015 -
toCalendar
Returns a view of this date/time as a Calendar object. Note that the returned Calendar object is entirely independent fromthisobject. Changes to the calendar will not affectthis. -
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. -
toHumanDisplayLocalTimezone
Returns a human readable version of this date/time using the system local format, converted to the local timezone if neccesary. -
isDateTime
- Overrides:
isDateTimein classBase
-
dateTimeValue
- Overrides:
dateTimeValuein classBase
-
hasTime
-
equalsUsingFhirPathRules
This method implements a datetime equality check using the rules as defined by FHIRPath (R2) Caveat: this implementation assumes local timezone for unspecified timezones -
compareTimes
-
fpValue
- Overrides:
fpValuein classPrimitiveType<Date>
-