Package org.openhab.core.library.types
Class DateTimeType
java.lang.Object
org.openhab.core.library.types.DateTimeType
- All Implemented Interfaces:
Comparable<DateTimeType>,Command,PrimitiveType,State,Type
@NonNullByDefault
public class DateTimeType
extends Object
implements PrimitiveType, State, Command, Comparable<DateTimeType>
- 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, Jimmy Tanagra - implement Comparable, Jacob Laursen - Refactored to use
Instantinternally
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newDateTimeTyperepresenting the current instant from the system clock.DateTimeType(String zonedValue) DateTimeType(Instant instant) Creates a newDateTimeTypewith the given value.DateTimeType(ZonedDateTime zoned) Creates a newDateTimeTypewith the given value. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanFormats the value of this type according to a pattern (seeFormatter).Get theInstantvalue of the objectDeprecated.getZonedDateTime(ZoneId zoneId) Get object represented as aZonedDateTimewith the the provided time-zone appliedinthashCode()Get a string representation that contains the whole internal representation of the type.toFullString(ZoneId zoneId) toString()static 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:
-
DATE_PATTERN_JSON_COMPAT
- See Also:
-
-
Constructor Details
-
DateTimeType
public DateTimeType()Creates a newDateTimeTyperepresenting the current instant from the system clock. -
DateTimeType
Creates a newDateTimeTypewith the given value.- Parameters:
instant-
-
DateTimeType
Creates a newDateTimeTypewith the given value. The time-zone information will be discarded, only the resultingInstantis preserved.- Parameters:
zoned-
-
DateTimeType
-
-
Method Details
-
getZonedDateTime
Deprecated.Get object represented as aZonedDateTimewith system default time-zone applied- Returns:
- a
ZonedDateTimerepresentation of the object
-
getZonedDateTime
Get object represented as aZonedDateTimewith the the provided time-zone applied- Returns:
- a
ZonedDateTimerepresentation of the object
-
getInstant
Get theInstantvalue of the object- Returns:
- the
Instantvalue of the object
-
valueOf
-
format
Description copied from interface:TypeFormats the value of this type according to a pattern (seeFormatter). -
format
-
format
-
toString
-
toFullString
Description copied from interface:TypeGet 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:
toFullStringin interfaceType- Returns:
- a full string representation of the type to be consumed by 'valueOf(String)'
-
toFullString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<DateTimeType>
-
ZonedDateTimewith system default time-zone applied