public interface DateTime extends Comparable<DateTime>, Serializable
If any date-time capabilities are required past what the current interface offers, clients are encouraged to use
the toZonedDateTime()
and toLocalDateTime()
and use the standard JDK java.time API.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DateTime other) |
long |
getMilliseconds()
Get the number of milliseconds from 1970-01-01T00:00Z.
|
long |
getMillisecondsInUtc()
Get the number of milliseconds from 1970-01-01T00:00Z with this time converted to UTC.
|
int |
getMillisOfSecond()
Get the milliseconds of the second value of this instance in time.
|
String |
getString()
Get the ISO-8601 representation of this instance in time.
|
String |
getTimeZoneId()
Get the identifier of the time zone in which this instant is defined
|
int |
getTimeZoneOffsetHours()
Get the number of hours that this time zone is offset from UTC.
|
boolean |
isAfter(DateTime other)
Return whether this date-time is later than the supplied date-time.
|
boolean |
isBefore(DateTime other)
Return whether this date-time is earlier than the supplied date-time.
|
boolean |
isSameAs(DateTime other)
Return whether this date-time is exactly the the same as the supplied date-time.
|
DateTime |
minus(Duration duration)
Subtract the specified amount.
|
DateTime |
plus(Duration duration)
Add the specified amount of time.
|
Calendar |
toCalendar()
Get this instance represented as a standard JDK
Calendar instance, in the default locale . |
Calendar |
toCalendar(Locale locale)
|
Date |
toDate()
Get this instance represented as a standard JDK
Date instance. |
LocalDateTime |
toLocalDateTime()
Get this instance represented as a standard JDK
LocalDateTime instance, which does not have any TZ information. |
DateTime |
toTimeZone(String timeZoneId)
Convert this time to the time zone given by the supplied identifier.
|
DateTime |
toUtcTimeZone()
Convert this time to the same instant in the UTC time zone.
|
ZonedDateTime |
toZonedDateTime()
Get this instance represented as a standard JDK
ZonedDateTime instance, which preserves the TZ information. |
String getString()
yyyy-mm-ddTHH:MM:SS.SSSZThe fields are separated by dashes and consist of:
HH:mm
(or '0' if UTC)long getMilliseconds()
Date
and Calendar
classes.long getMillisecondsInUtc()
Date
and Calendar
classes.Date toDate()
Date
instance. Note that this conversion loses the time
zone information, as the standard JDK Date
does not represent time zones.ZonedDateTime toZonedDateTime()
ZonedDateTime
instance, which preserves the TZ information.LocalDateTime toLocalDateTime()
LocalDateTime
instance, which does not have any TZ information.Calendar toCalendar()
Calendar
instance, in the default locale
.Calendar toCalendar(Locale locale)
locale
- the locale in which the Calendar instance is desired; may be null if the default
locale
is to be used.int getMillisOfSecond()
int getTimeZoneOffsetHours()
String getTimeZoneId()
DateTime toUtcTimeZone()
DateTime toTimeZone(String timeZoneId)
timeZoneId
- the time zone identifierIllegalArgumentException
- if the time zone identifier is null or is invalidboolean isBefore(DateTime other)
other
- the date-time to compare withcompareTo(DateTime)
,
isSameAs(DateTime)
,
isAfter(DateTime)
boolean isAfter(DateTime other)
other
- the date-time to compare withcompareTo(DateTime)
,
isBefore(DateTime)
,
isSameAs(DateTime)
boolean isSameAs(DateTime other)
the equals method
in that it can be arbitrarily more strict, checking, for example, not only the logical equivalence of
the other date time, but also arbitrary additional fields such as the time zone.other
- the date-time to compare withcompareTo(DateTime)
,
isBefore(DateTime)
,
isAfter(DateTime)
DateTime minus(Duration duration)
duration
- the amount of time; may not be nullDateTime plus(Duration duration)
duration
- the amount of time; may not be nullint compareTo(DateTime other)
compareTo
in interface Comparable<DateTime>
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.