Java.util.GregorianCalendar.roll() 方法 Java.util.GregorianCalendar.isLeapYear() 方法 Java.util.EnumSet.of() 方法 Java.util.GregorianCalendar.roll() 方法 package com.codingdict; import java.util.*; public class GregorianCalendarDemo { public static void main(String[] args) { // create a new calendar GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); // print the current date and time System.out.println("" + cal.getTime()); // roll a month cal.roll(GregorianCalendar.MONTH, true); System.out.println("Date:" + cal.getTime()); // roll a year backwards cal.roll(GregorianCalendar.YEAR, false); System.out.println("Date:" + cal.getTime()); } } Java.util.GregorianCalendar.isLeapYear() 方法 Java.util.EnumSet.of() 方法