Java Calendar.computeFields()
Syntax
Calendar.computeFields() has the following syntax.
protected abstract void computeFields()
Example
In the following code shows how to use Calendar.computeFields() method.
/*from w ww . j av a 2 s . c o m*/
import java.util.GregorianCalendar;
public class Main extends GregorianCalendar {
public static void main(String[] args) {
Main cal = new Main();
// clear the calendar
cal.clear();
// set a new year and call computeFields()
cal.set(GregorianCalendar.YEAR, 2013);
cal.computeFields();
// print the current date
System.out.println("New date is : " + cal.getTime());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »