public final class Now
extends java.lang.Object
An instance of Now
always obtains the current time in
different formats. The time zone is fixed for a given instance.
Modifier and Type | Method and Description |
---|---|
DayOfWeek |
asDayOfWeek()
Obtains the current day of week.
|
LocalDate |
asLocalDate()
Obtains the current time as a
LocalDate . |
LocalDateTime |
asLocalDateTime()
Obtains the current time as a
LocalDateTime . |
LocalTime |
asLocalTime()
Obtains the current time as a
LocalTime . |
Month |
asMonth()
Obtains the current month.
|
OffsetDateTime |
asOffsetDateTime()
Obtains the current time as an
OffsetDateTime . |
OffsetTime |
asOffsetTime()
Obtains the current time as an
OffsetTime . |
YearMonth |
asYearMonth()
Obtains the current year and month.
|
ZonedDateTime |
asZonedDateTime()
Obtains the current time as an
ZonedDateTime . |
static Now |
get()
Obtains the
Now in the current time zone provided by Time.currentTimeZone() . |
static Now |
get(java.time.ZoneId timeZone)
Obtains the
Now in the given time zone. |
static Now |
get(ZoneId timeZone)
Obtains the
Now in the given time zone. |
static Now |
get(ZoneOffset offset)
Obtains the
Now with the given zone offset. |
public static Now get(java.time.ZoneId timeZone)
Now
in the given time zone.timeZone
- the time zone to obtain time inpublic static Now get()
Now
in the current time zone provided by Time.currentTimeZone()
.
Note that the time zone of the resulting instance will never change, even if
the Time.currentTimeZone()
changes.
public static Now get(ZoneId timeZone)
Now
in the given time zone.timeZone
- the time zone to obtain time inpublic static Now get(ZoneOffset offset)
Now
with the given zone offset.offset
- the time zone offsetpublic Month asMonth()
public YearMonth asYearMonth()
public DayOfWeek asDayOfWeek()
public LocalDate asLocalDate()
LocalDate
.public LocalTime asLocalTime()
LocalTime
.public LocalDateTime asLocalDateTime()
LocalDateTime
.public OffsetTime asOffsetTime()
OffsetTime
.public OffsetDateTime asOffsetDateTime()
OffsetDateTime
.public ZonedDateTime asZonedDateTime()
ZonedDateTime
.