Java: Convert Date Class Object to Calendar

import java.util.Calendar;
import java.util.Date;

public class GetDateTimeZoned {

    public static void main(String[] args) {

        Date currentDate = new Date();
        Calendar calendar = convertDateToCalendar(currentDate);


    public static Calendar convertDateToCalendar(Date date) {
        Calendar calendar = Calendar.getInstance();
        return calendar;

You can convert java.util.Date class object to java.util.Calendar in three easy steps,

  1. Crete an instance of Date object.
  2. Create an instance of Calendar object.
  3. Now make use of the setTime(Date date) method on the Calendar object to convert the date into the calendar.

One should try and avoid using Date and Calendar classes from java.util package and move the Date-Time API introduced in Java 8.


Have Questions? Post them here!