Package org.openhab.core.library.types
Class DateTimeType
java.lang.Object
org.openhab.core.library.types.DateTimeType
- All Implemented Interfaces:
Command
,PrimitiveType
,State
,Type
- Author:
- Kai Kreuzer - Initial contribution, Erdoan Hadzhiyusein - Refactored to use ZonedDateTime, Jan N. Klug - add ability to use time or date only, Wouter Born - increase parsing and formatting precision, Laurent Garnier - added methods toLocaleZone and toZone, Gaƫl L'hopital - added ability to use second and milliseconds unix time
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Formats the value of this type according to a pattern (seeFormatter
).Get curent object represented as anInstant
int
hashCode()
Get a string representation that contains the whole internal representation of the type.Create aDateTimeType
being the translation of the current object to the locale time zonetoString()
Create aDateTimeType
being the translation of the current object to a given zoneCreate aDateTimeType
being the translation of the current object to a given zonestatic DateTimeType
-
Field Details
-
DATE_PATTERN
- See Also:
-
DATE_PATTERN_WITH_TZ
- See Also:
-
DATE_PATTERN_WITH_TZ_AND_MS
- See Also:
-
DATE_PATTERN_WITH_TZ_AND_MS_GENERAL
- See Also:
-
DATE_PATTERN_WITH_TZ_AND_MS_ISO
- See Also:
-
-
Constructor Details
-
DateTimeType
public DateTimeType() -
DateTimeType
-
DateTimeType
-
-
Method Details
-
getZonedDateTime
-
getInstant
Get curent object represented as anInstant
- Returns:
- an
Instant
representation of the current object
-
valueOf
-
format
Description copied from interface:Type
Formats the value of this type according to a pattern (seeFormatter
). -
format
-
toLocaleZone
Create aDateTimeType
being the translation of the current object to the locale time zone- Returns:
- a
DateTimeType
translated to the locale time zone - Throws:
DateTimeException
- if the converted zone ID has an invalid format or the result exceeds the supported date rangeZoneRulesException
- if the converted zone region ID cannot be found
-
toZone
Create aDateTimeType
being the translation of the current object to a given zone- Parameters:
zone
- the target zone as a string- Returns:
- a
DateTimeType
translated to the given zone - Throws:
DateTimeException
- if the zone has an invalid format or the result exceeds the supported date rangeZoneRulesException
- if the zone is a region ID that cannot be found
-
toZone
Create aDateTimeType
being the translation of the current object to a given zone- Parameters:
zoneId
- the targetZoneId
- Returns:
- a
DateTimeType
translated to the given zone - Throws:
DateTimeException
- if the result exceeds the supported date range
-
toString
-
toFullString
Description copied from interface:Type
Get a string representation that contains the whole internal representation of the type.The returned string could be consumed by the static 'valueOf(String)' method of the respective type to build a new type that is equal to this type.
- Specified by:
toFullString
in interfaceType
- Returns:
- a full string representation of the type to be consumed by 'valueOf(String)'
-
hashCode
public int hashCode() -
equals
-