Java Calendar computeFields 方法 Java示例-检查Socket端口 Java Calendar computeTime方法 Java Calendar computeFields 方法 package com.codingdict; import java.util.*; public class CalendarDemo extends GregorianCalendar { public static void main(String[] args) { // create a new calendar CalendarDemo cal = new CalendarDemo(); // print the current date System.out.println("The current date is : " + cal.getTime()); // clear the calendar cal.clear(); // set a new year and call computeFields() cal.set(GregorianCalendar.YEAR, 1998); cal.computeFields(); // print the current date System.out.println("New date is : " + cal.getTime()); } } Java示例-检查Socket端口 Java Calendar computeTime方法