Package org.hl7.fhir.dstu2.model
Class BaseDateTimeType
- java.lang.Object
-
- org.hl7.fhir.dstu2.model.Base
-
- org.hl7.fhir.dstu2.model.Element
-
- org.hl7.fhir.dstu2.model.Type
-
- org.hl7.fhir.dstu2.model.PrimitiveType<Date>
-
- org.hl7.fhir.dstu2.model.BaseDateTimeType
-
- All Implemented Interfaces:
ca.uhn.fhir.model.api.IElement,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
public abstract class BaseDateTimeType extends PrimitiveType<Date>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BaseDateTimeType()ConstructorBaseDateTimeType(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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(int theField, int theValue)Adds the given amount to the field specified by theFieldbooleanafter(DateTimeType theDateTimeType)booleanbefore(DateTimeType theDateTimeType)protected Stringencode(Date theValue)Subclasses must override to convert a "coerced" value into an encoded one.protected abstract ca.uhn.fhir.model.api.TemporalPrecisionEnumgetDefaultPrecisionForDatatype()Returns the default precision for the given datatypeca.uhn.fhir.model.api.TemporalPrecisionEnumgetPrecision()Gets the precision for this datatype (using the default for the given type if not set)longgetTime()Returns the time in millis as represented by this Date/TimeTimeZonegetTimeZone()Returns the TimeZone associated with this dateTime's value.booleanisTimeZoneZulu()booleanisToday()Returnstrueif this object represents a date that is today's dateprotected Dateparse(String theValue)Subclasses must override to convert an encoded representation of this datatype into a "coerced" onevoidsetOffsetMinutes(int theZoneOffsetMinutes)Sets the TimeZone offset in minutes relative to GMTvoidsetPrecision(ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision)Sets the precision for this datatype using field values fromCalendar.voidsetTimeZone(TimeZone theTimeZone)voidsetTimeZoneZulu(boolean theTimeZoneZulu)BaseDateTimeTypesetValue(Date theValue)Sets the value of this date/time using the default level of precision for this datatype using the system local time zonevoidsetValue(Date theValue, ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision)Sets the value of this date/time using the specified level of precision using the system local time zonevoidsetValueAsString(String theValue)protected voidsetValueAsV3String(String theV3String)CalendartoCalendar()Returns a view of this date/time as a Calendar objectStringtoHumanDisplay()Returns a human readable version of this date/time using the system local format.StringtoHumanDisplayLocalTimezone()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.dstu2.model.PrimitiveType
asStringValue, copy, equalsDeep, equalsShallow, fromStringValue, getValue, getValueAsString, hashCode, hasValue, isEmpty, isPrimitive, primitiveValue, toString, typedCopy, updateStringValue
-
Methods inherited from class org.hl7.fhir.dstu2.model.Element
addChild, addExtension, addExtension, copyValues, fhirType, getExtension, getExtensionsByUrl, getExtensionString, getId, getIdElement, hasExtension, hasExtension, hasId, hasIdElement, listChildren, setId, setIdElement, setProperty
-
Methods inherited from class org.hl7.fhir.dstu2.model.Base
castToAddress, castToAnnotation, castToAttachment, castToBase64Binary, castToBoolean, castToCode, castToCodeableConcept, castToCoding, castToContactPoint, castToDate, castToDateTime, castToDecimal, castToDuration, castToElementDefinition, castToExtension, castToHumanName, castToId, castToIdentifier, castToInstant, castToInteger, castToMarkdown, castToMeta, castToMoney, castToNarrative, castToOid, castToPeriod, castToPositiveInt, castToQuantity, castToRange, castToRatio, castToReference, castToResource, castToSampledData, castToSignature, castToSimpleQuantity, castToString, castToTime, castToTiming, castToUnsignedInt, castToUri, children, compareDeep, compareDeep, compareDeep, compareValues, compareValues, equals, getChildByName, getFormatCommentsPost, getFormatCommentsPre, getUserData, getUserInt, getUserString, hasFormatComment, hasType, hasUserData, isMetadataBased, listChildrenByName, setUserData, setUserDataINN
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hl7.fhir.instance.model.api.IBase
fhirType, getFormatCommentsPost, getFormatCommentsPre, getUserData, hasFormatComment, setUserData
-
-
-
-
Constructor Detail
-
BaseDateTimeType
public BaseDateTimeType()
Constructor
-
BaseDateTimeType
public BaseDateTimeType(Date theDate, ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision)
Constructor- Throws:
IllegalArgumentException- If the specified precision is not allowed for this type
-
BaseDateTimeType
public BaseDateTimeType(String theString)
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
-
-
Method Detail
-
encode
protected String encode(Date theValue)
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
-
getDefaultPrecisionForDatatype
protected abstract ca.uhn.fhir.model.api.TemporalPrecisionEnum getDefaultPrecisionForDatatype()
Returns the default precision for the given datatype
-
getPrecision
public ca.uhn.fhir.model.api.TemporalPrecisionEnum getPrecision()
Gets the precision for this datatype (using the default for the given type if not set)- See Also:
setPrecision(TemporalPrecisionEnum)
-
getTimeZone
public TimeZone getTimeZone()
Returns the TimeZone associated with this dateTime's value. May returnnullif no timezone was supplied.
-
isTimeZoneZulu
public boolean isTimeZoneZulu()
-
isToday
public boolean isToday()
Returnstrueif this object represents a date that is today's date- Throws:
NullPointerException- ifPrimitiveType.getValue()returnsnull
-
parse
protected Date parse(String theValue) throws IllegalArgumentException
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:
IllegalArgumentException
-
setPrecision
public void setPrecision(ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision) throws IllegalArgumentException
Sets the precision for this datatype using field values fromCalendar. Valid values are:- Throws:
IllegalArgumentException
-
setTimeZone
public void setTimeZone(TimeZone theTimeZone)
-
setTimeZoneZulu
public void setTimeZoneZulu(boolean theTimeZoneZulu)
-
setValue
public BaseDateTimeType setValue(Date theValue)
Sets the value of this date/time using the default level of precision for this datatype using the system local time zone- Specified by:
setValuein interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<Date>- Overrides:
setValuein classPrimitiveType<Date>- Parameters:
theValue- The date value
-
setValue
public void setValue(Date theValue, ca.uhn.fhir.model.api.TemporalPrecisionEnum thePrecision) throws IllegalArgumentException
Sets the value of this date/time using the specified level of precision using the system local time zone- Parameters:
theValue- The date valuethePrecision- The precision- Throws:
IllegalArgumentException
-
setValueAsString
public void setValueAsString(String theValue) throws IllegalArgumentException
- Specified by:
setValueAsStringin interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<Date>- Overrides:
setValueAsStringin classPrimitiveType<Date>- Throws:
IllegalArgumentException
-
before
public boolean before(DateTimeType theDateTimeType)
-
after
public boolean after(DateTimeType theDateTimeType)
-
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.
-
toHumanDisplayLocalTimezone
public String toHumanDisplayLocalTimezone()
Returns a human readable version of this date/time using the system local format, converted to the local timezone if neccesary.
-
toCalendar
public Calendar toCalendar()
Returns a view of this date/time as a Calendar object
-
setOffsetMinutes
public void setOffsetMinutes(int theZoneOffsetMinutes)
Sets the TimeZone offset in minutes relative to GMT
-
getTime
public long getTime()
Returns the time in millis as represented by this Date/Time
-
add
public void add(int theField, int theValue)
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)
-
setValueAsV3String
protected void setValueAsV3String(String theV3String)
-
-