Date to Calendar Java

Date to Calendar Java

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.

Date to Calendar JavaOutput screen on Date to Calendar conversion Example

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

1. Date Calendar Conversions

2 thoughts on “Date to Calendar Java

Leave a Reply

Your email address will not be published. Required fields are marked *