Sometimes in Java, it is necessary to convert in between Date to Calendar and Calendar to Date classes.
Note: It is assumed that you know about the basic concepts of class Date and class GregorianCalendar.
It is done in the following code.
import java.util.*;
public class DateToCalendar
{
public static void main(String args[])
{
Date d1 = new Date(); // create java.util.Date object
System.out.println(d1);
Calendar cal1 = Calendar.getInstance(); // create Calendar object
cal1.setTime(d1); // now Date comes into Calendar
System.out.println(cal1);
}
}

Create Date object and pass it to setTime() method of Calendar class. Calendar is abstract class. You cannot create object directly.
A. Following postings of this same Web site give all the possible operations on Date and Time manipulations.
1. class Date
2. class GregorianCalendar
3. SimpleDateFormat to set time as per the country with Locale
4. SimpleDateFormat to convert Date object to String form
5. SimpleDateFormat to convert String to Date
6. Java Dates Comparison
B. Conversions between java.util.Date, java.util.Calendar and java.sql.Date
Please Provide the Objective Question too….. Then we w’ll prepared more
OK. You will shortly.