round method

  1. @Possible({RangeError})
  2. @useResult
LocalDateTime round(
  1. TemporalUnit unit,
  2. int value
)

Returns a copy of this rounded to the nearest unit and value.

Contract

Throws RangeError if value <= 0.

Example

LocalDateTime(2023, 4, 15, 12, 30).round(DateUnit.months, 6); // 2023-06-01 00:00

LocalDateTime(2023, 8, 15, 12, 30).round(DateUnit.months, 6); // 2023-06-01 00:00

Implementation

@Possible({RangeError})
@useResult LocalDateTime round(TemporalUnit unit, int value) => LocalDateTime._(_native.round(unit, value));