LocalDateTime.of constructor

LocalDateTime.of(
  1. int year,
  2. int month,
  3. int day,
  4. int hour,
  5. int minute, [
  6. int second = 0,
  7. int millisecond = 0,
])

Creates a LocalDateTime from individual components.

second and millisecond are optional and default to 0.

Example:

final dt = LocalDateTime.of(2025, 6, 27, 14, 30);

A date-time object without a timezone, composed of a LocalDate and LocalTime.

This class represents a specific moment on a calendar, combining a date and time without referencing any timezone. It is immutable and supports arithmetic and comparison operations.

Example:

final dateTime = LocalDateTime.of(2024, 12, 31, 23, 59);
print(dateTime); // 2024-12-31T23:59:00

Implementation

LocalDateTime.of(int year, int month, int day, int hour, int minute, [int second = 0, int millisecond = 0])
    : date = LocalDate(year, month, day),
      time = LocalTime(hour, minute, second, millisecond);