LocalDateTime class
A date-time without a time-zone, such as July 20, 1969, 8:18pm.
- Implemented types
- Available extensions
Constructors
- LocalDateTime(LocalDate date, LocalTime time)
-
Constructs a new LocalDateTime by combining a
date
with atime
. - LocalDateTime.from(Temporal temporal)
-
Constructs a new LocalDateTime instance
from the given temporal.
factory
- LocalDateTime.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch, ZoneId zone)
-
Constructs a new LocalDateTime instance
with the given
microsecondsSinceEpoch
.factory - LocalDateTime.now()
-
Constructs a new LocalDateTime instance with current date and time
in the local time zone.
factory
- LocalDateTime.parse(String formattedString)
-
Constructs a new LocalDateTime instance based on
formattedString
.factory
Properties
- dayOfMonth → int
-
The day of the month
[1..31]
.no setter - dayOfWeek → DayOfWeek
-
The day of the week
[monday..sunday]
.no setter - epochDay → int
-
The epoch-day. Count of days since epoch (1970-01-01).
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- hour → int
-
The hour of the day, expressed as in a 24-hour clock
[0..23]
.no setter - isLeapYear → bool
-
Returns true if year is a leap year.
no setter
- localDate → LocalDate
-
final
- localTime → LocalTime
-
final
- microsecond → int
-
The microsecond
[0...999]
.no setter - microsecondOfDay → int
-
The microsecond of day.
no setter
- millisecond → int
-
The millisecond
[0...999]
.no setter - minute → int
-
The minute
[0...59]
.no setter - month → int
-
The month
[1..12]
.no setter - prolepticMonth → int
-
The proleptic month. Count of months since year 0.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
The second
[0...59]
.no setter - year → int
-
The year.
no setter
Methods
-
adjust(
ChronoField field, int newValue) → LocalDateTime -
Returns a new instance of this Temporal
with the given
field
adjusted tonewValue
.override -
atEndOfMonth(
) → T -
Available on T, provided by the TemporalAdjusters extension
Returns a new instance of this Temporal at the end of the month. -
atStartOfMonth(
) → T -
Available on T, provided by the TemporalAdjusters extension
Returns a new instance of this Temporal at the start of the month. -
atStartOfWeek(
[String? locale]) → T -
Available on T, provided by the TemporalWeekFields extension
Returns a new instance of this Temporal at the start of the week. -
atZone(
ZoneId zone) → ZonedDateTime -
Available on LocalDateTime, provided by the LocalDateTimeWithZone extension
Combines this LocalDateTime with the givenzone
into a new ZonedDateTime instance. -
compareTo(
LocalDateTime other) → int -
Compares this object to another object.
override
-
copyWith(
{int? year, int? month, int? dayOfMonth, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → LocalDateTime - Returns a new instance of this LocalDateTime with the given individual properties adjusted.
-
get(
ChronoField field) → int -
Returns the value for the given
field
of this Temporal.override -
minus(
int amountToSubtract, ChronoUnit unit) → LocalDateTime -
Returns a new instance of this Temporal
with the given
amount
subtracted.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
plus(
int amountToAdd, ChronoUnit unit) → LocalDateTime -
Returns a new instance of this Temporal
with the given
amount
added.override -
toString(
) → String -
A string representation of this object.
override
-
until(
Temporal endExclusive, ChronoUnit unit) → int -
Returns the difference in the given
unit
between this Temporal andendExclusive
.override
Operators
-
operator +(
TemporalAmount amount) → LocalDateTime -
Returns a new instance of this Temporal
with the given
amount
added.override -
operator -(
TemporalAmount amount) → LocalDateTime -
Returns a new instance of this Temporal
with the given
amount
subtracted.override -
operator <(
LocalDateTime other) → bool -
Whether this LocalDateTime occurs before
other
. -
operator <=(
LocalDateTime other) → bool -
Whether this LocalDateTime occurs before or at the same moment as
other
. -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
LocalDateTime other) → bool -
Whether this LocalDateTime occurs after
other
. -
operator >=(
LocalDateTime other) → bool -
Whether this LocalDateTime occurs after or at the same moment as
other
.