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
Instant
internally
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newDateTimeType
representing the current instant from the system clock.DateTimeType
(String zonedValue) DateTimeType
(Instant instant) Creates a newDateTimeType
with the given value.DateTimeType
(ZonedDateTime zoned) Creates a newDateTimeType
with the given value. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Formats the value of this type according to a pattern (seeFormatter
).Get theInstant
value of the objectDeprecated.getZonedDateTime
(ZoneId zoneId) Get object represented as aZonedDateTime
with the the provided time-zone appliedint
hashCode()
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 newDateTimeType
representing the current instant from the system clock. -
DateTimeType
Creates a newDateTimeType
with the given value.- Parameters:
instant
-
-
DateTimeType
Creates a newDateTimeType
with the given value. The time-zone information will be discarded, only the resultingInstant
is preserved.- Parameters:
zoned
-
-
DateTimeType
-
-
Method Details
-
getZonedDateTime
Deprecated.Get object represented as aZonedDateTime
with system default time-zone applied- Returns:
- a
ZonedDateTime
representation of the object
-
getZonedDateTime
Get object represented as aZonedDateTime
with the the provided time-zone applied- Returns:
- a
ZonedDateTime
representation of the object
-
getInstant
Get theInstant
value of the object- Returns:
- the
Instant
value of the object
-
valueOf
-
format
Description copied from interface:Type
Formats the value of this type according to a pattern (seeFormatter
). -
format
-
format
-
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)'
-
toFullString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<DateTimeType>
-
ZonedDateTime
with system default time-zone applied