Convert Date To Calendar
In this example we are converting date into Calendar. Here we are using format method to convert date into string.
We are using java.util. Calendar class in this example. The GregorianCalendar
class is subclass of the Calendar class. Calendar is an abstract
base class for converting between a Date object and a set of integer
fields such as YEAR, MONTH, DAY, HOUR, and so on. A Date object represents
a specific instant of time with millisecond precision The subclasses of Calendar
class interpret a Date according to the rules of a
specific calendar system. Calendar class provides a class method
getInstance to get a generally useful object of this type.
Calendar's getInstance method returns a Calendar object whose time fields
have been initialized with the current date and time. e.g
The code of the program is given below:
The output of the program is given below: