Java Date Time Java Java API
java.time.ZonedDateTime
public ZonedDateTime withYear(int year)
package com.logicbig.example.zoneddatetime;import java.time.ZonedDateTime;public class WithYearExample { public static void main(String... args) { ZonedDateTime d = ZonedDateTime.now(); System.out.println(d); ZonedDateTime d2 = d.withYear(2000); System.out.println(d2); }}
2025-10-29T18:29:47.787+08:00[America/Chicago]2000-10-29T18:29:47.787+08:00[America/Chicago]