public static class DateTime.Context
extends Object
Constructor and Description |
---|
Context()
Constructs an instance.
|
Context(TimeZone timeZone)
Constructs an instance.
|
Context(ZoneId zoneId)
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
DateTime |
fromFields(DateTime.Fields fields)
Returns a DateTime built from fields.
|
DateTime |
fromString(String timeString)
Returns a DateTime decoded from a time string.
|
DateTime |
fromString(String timeString,
Optional<DateTime> reference)
Returns a DateTime decoded from a time string.
|
int |
getDayOfWeek(DateTime dateTime)
Gets the day of week for a DateTime.
|
int |
getDaysInMonth(DateTime dateTime)
Gets the number of days in the month of a DateTime.
|
TimeZone |
getTimeZone()
Gets the time zone.
|
ZoneId |
getZoneId()
Gets the ZoneId.
|
DateTime |
midnight(DateTime dateTime)
Returns a DateTime from a DateTime at midnight.
|
DateTime |
nextDay(DateTime dateTime)
Returns a DateTime from a DateTime at midnight on the next day.
|
DateTime |
noon(DateTime dateTime)
Returns a DateTime from a DateTime at noon.
|
DateTime |
previousDay(DateTime dateTime)
Returns a DateTime from a DateTime at midnight on the previous day.
|
String |
toBaseString(DateTime dateTime)
Provides a base string representation of a DateTime.
|
DateTime.Fields |
toFields(DateTime dateTime)
Returns the fields from a DateTime.
|
String |
toFullString(DateTime dateTime)
Provides a full extended string representation of a DateTime.
|
String |
toOrdinalString(DateTime dateTime)
Provides an ordinal string representation of a DateTime.
|
String |
toString() |
String |
toString(DateTime dateTime)
Provides a string representation of a DateTime.
|
String |
toURLString(DateTime dateTime)
Provides a URL compatible representation of a DateTime.
|
ZonedDateTime |
toZonedDateTime(DateTime dateTime)
Returns a ZonedDateTime for a DateTime.
|
public Context()
public Context(@Nonnull TimeZone timeZone)
timeZone
- The TimeZone.public Context(@Nonnull ZoneId zoneId)
zoneId
- The ZoneId.@Nonnull @CheckReturnValue public DateTime fromFields(@Nonnull DateTime.Fields fields)
fields
- The fields.@Nonnull @CheckReturnValue public DateTime fromString(@Nonnull String timeString)
It accepts as input the output of toString()
,
DateTime.toFullString()
, DateTime.toHexString()
or
Timestamp.toString()
.
timeString
- The required and not empty time String.IllegalArgumentException
- When the time String is invalid.@Nonnull @CheckReturnValue public DateTime fromString(@Nonnull String timeString, @Nonnull Optional<DateTime> reference) throws IllegalArgumentException
It accepts as input the output of toString()
,
DateTime.toFullString()
, DateTime.toHexString()
or
Timestamp.toString()
. It will return null for a null
input.
timeString
- The required and not empty time String.reference
- An optional reference date to use when the year is
missing.IllegalArgumentException
- When the time String is invalid.@CheckReturnValue public int getDayOfWeek(@Nonnull DateTime dateTime)
dateTime
- The DateTime.@CheckReturnValue public int getDaysInMonth(@Nonnull DateTime dateTime)
dateTime
- The DateTime.@Nonnull @CheckReturnValue public TimeZone getTimeZone()
@Nonnull @CheckReturnValue public ZoneId getZoneId()
@Nonnull @CheckReturnValue public DateTime midnight(@Nonnull DateTime dateTime)
dateTime
- The original DateTime.@Nonnull @CheckReturnValue public DateTime nextDay(@Nonnull DateTime dateTime)
dateTime
- The original DateTime.@Nonnull @CheckReturnValue public DateTime noon(@Nonnull DateTime dateTime)
dateTime
- The original DateTime.@Nonnull @CheckReturnValue public DateTime previousDay(@Nonnull DateTime dateTime)
dateTime
- The original DateTime.@Nonnull @CheckReturnValue public String toBaseString(@Nonnull DateTime dateTime)
Generates a base string in ISO 8601 format adjusted to astronomical conventions.
dateTime
- The DateTime.@Nonnull @CheckReturnValue public DateTime.Fields toFields(@Nonnull DateTime dateTime)
dateTime
- The DateTime.@Nonnull @CheckReturnValue public String toFullString(@Nonnull DateTime dateTime)
Generates an extended string in ISO 8601 format adjusted to astronomical conventions.
dateTime
- The DateTime.@Nonnull @CheckReturnValue public String toOrdinalString(@Nonnull DateTime dateTime)
Generates a string in ISO 8601 format adjusted to astronomical conventions with the date in ordinal (yyyy-ddd) representation.
dateTime
- The DateTime.public String toString()
toString
in class Object
@Nonnull @CheckReturnValue public String toString(@Nonnull DateTime dateTime)
Generates a string in ISO 8601 format adjusted to astronomical conventions.
dateTime
- The DateTime.@Nonnull @CheckReturnValue public String toURLString(@Nonnull DateTime dateTime)
dateTime
- The DateTime.@Nonnull @CheckReturnValue public ZonedDateTime toZonedDateTime(@Nonnull DateTime dateTime)
dateTime
- The DateTime.Copyright © 2003-2019 Serge Brisson. All Rights Reserved.