Online Java Compiler By
JavaTpoint.com
import java.util.*; public class JavaCalendarisSetExample1 { public static void main(String[] args) { // create a calendar object calobj Calendar calobj = Calendar.getInstance(); // display the current date System.out.println(" Today " + calobj.getTime()); // determine if the given calendar field has a value set boolean b = calobj.isSet(Calendar.YEAR); System.out.println("Year is set: " + b); calobj.clear(Calendar.YEAR); // determine if the given calendar field has a value set b = calobj.isSet(Calendar.YEAR); System.out.println("Year is set: " + b); } }
Output