withYear method

  1. @override
Gregorian withYear(
  1. int year
)
override

Make a new date object with changed year

Original date object remains unchanged

This method is NOT safe

Throws DateException on problems

Note: For changing at once use copy() methods

Note: You can chain methods

Implementation

@override
Gregorian withYear(int year) {
  if (year == this.year) {
    return this;
  } else {
    return Gregorian(
      year,
      month,
      day,
      hour,
      minute,
      second,
      millisecond,
    );
  }
}