LocalDateTime class Local times
A date and time with no time zone.
This is a combination of LocalDate and LocalTime. The individual parts can be retrieved with date and time.
- Implemented types
- Annotations
-
- @immutable
Constructors
- LocalDateTime([int year = 0, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int nanosecond = 0])
-
Constructs a new
LocalDateTime. - LocalDateTime.combine(LocalDate date, [LocalTime? time])
-
Makes a
LocalDateTimefrom a LocalDate and an optional LocalTime. - LocalDateTime.fromDateTime(DateTime dateTime)
-
Constructs a
LocalDateTimefrom a standard Dart DateTime. The timezone (if any) ofdateTimeis ignored. - LocalDateTime.now()
-
Constructs a
LocalDateTimewith the current date and time in the current time zone. - LocalDateTime.parse(String dateTime)
-
Parses an ISO 8601 datetime string. Discards the zone offset (if any).
factory
Properties
- date → LocalDate
-
The date part of this DateTime.
final
- day → int
-
The day starting at 1.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setteroverride
- hour → int
-
The hour from 0 to 23.
no setteroverride
- minute → int
-
The minute from 0 to 59.
no setteroverride
- month → int
-
The month from 1 to 12.
no setteroverride
- nanosecond → int
-
The nanoseconds from 0 to 999,999,999.
no setteroverride
- ordinalDay → int
-
The number of days since the beginning of the year.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
The second from 0 to 59.
no setteroverride
- time → LocalTime
-
The time part of this DateTime.
final
- weekday → Weekday
-
The day of the week.
no setteroverride
- year → int
-
The year.
no setteroverride
Methods
-
atOffset(
[ZoneOffset? offset]) → OffsetDateTime - Converts this to an OffsetDateTime with the given offset.
-
compareTo(
LocalDateTime other) → int -
Compares this object to another object.
override
-
inTimezone(
[String? zoneId]) → ZonedDateTime - Converts this to a ZonedDateTime.
-
minusPeriod(
Period amount) → LocalDateTime - Subtracts a Period of time.
-
minusTimespan(
Timespan amount) → LocalDateTime - Subtracts a Timespan.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
periodUntil(
HasDate other) → Period - Finds the Period between this and another HasDate.
-
plusPeriod(
Period amount) → LocalDateTime - Adds a Period of time.
-
plusTimespan(
Timespan amount) → LocalDateTime - Adds a Timespan.
-
replace(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? nanosecond}) → LocalDateTime - Returns a new datetime with one or more fields replaced.
-
timespanUntil(
LocalDateTime other) → Timespan -
Finds the timespan between this and
other. -
toDateTime(
) → DateTime - Converts this to a DateTime.
-
toInstant(
) → Instant - Converts this to an Instant.
-
toLocal(
) → LocalDateTime - Returns this unchanged. Provided for completeness.
-
toString(
) → String -
Returns the date and time in ISO 8601 format.
override
Operators
-
operator <(
LocalDateTime other) → bool - Less than operator.
-
operator <=(
LocalDateTime other) → bool - Less than or equals operator.
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
LocalDateTime other) → bool - Greater than operator.
-
operator >=(
LocalDateTime other) → bool - Greater than or equals operator.
Static Properties
- maximum → LocalDateTime
-
The latest possible datetime.
final
- minimum → LocalDateTime
-
The earliest possible datetime.
final