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.const - 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. - 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.
no setter
- day → int
-
The day starting at 1.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- hour → int
-
The hour from 0 to 23.
no setterinherited
- inLeapYear → bool
-
Determines if this date falls in a leap year.
no setterinherited
- minute → int
-
The minute from 0 to 59.
no setterinherited
- month → int
-
The month from 1 to 12.
no setterinherited
- nanosecond → int
-
The nanoseconds from 0 to 999,999,999.
no setterinherited
- ordinalDay → int
-
The number of days since the beginning of the year.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
The second from 0 to 59.
no setterinherited
- time → LocalTime
-
The time part of this DateTime.
no setter
- weekday → Weekday
-
The day of the week.
no setterinherited
- year → int
-
The year.
no setterinherited
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
-
format(
DateFormat format) → String -
Formats this object using the given format.
inherited
-
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.
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.
Constants
- maximum → const LocalDateTime
- The latest possible datetime.
- minimum → const LocalDateTime
- The earliest possible datetime.