setYear method

DateTime setYear(
  1. int year, [
  2. int? month,
  3. int? day,
  4. int? hour,
  5. int? minute,
  6. int? second,
  7. int? millisecond,
  8. int? microsecond,
])

Change year of this date

set month if you want to change it as well, to skip an change other optional field set it as null set day if you want to change it as well, to skip an change other optional field set it as null set hour if you want to change it as well, to skip an change other optional field set it as null set minute if you want to change it as well, to skip an change other optional field set it as null set second if you want to change it as well, to skip an change other optional field set it as null set millisecond if you want to change it as well, to skip an change other optional field set it as null set microsecond if you want to change it as well

Implementation

DateTime setYear(
  int year, [
  int? month,
  int? day,
  int? hour,
  int? minute,
  int? second,
  int? millisecond,
  int? microsecond,
]) =>
    DateTime(
      year,
      month ?? this.month,
      day ?? this.day,
      hour ?? this.hour,
      minute ?? this.minute,
      second ?? this.second,
      millisecond ?? this.millisecond,
      microsecond ?? this.microsecond,
    );