Java示例滚动月


Java示例滚动月

import java.util.Calendar;



public class CalendarExample {

   public static void main(String[] args) {

      Calendar cal = Calendar.getInstance();

        System.out.println("Time:" + cal.getTime());



      cal.roll(Calendar.YEAR, false);

        System.out.println("Time rolling down the year:" + cal.getTime());



      cal.roll(Calendar.HOUR, true);

        System.out.println("Time rolling up the hour:" + cal.getTime());

   }

}