Java DateFormat getCalendar() Example

DateFormat class getCalendar() method example. This example shows you how to use getCalendar() method.


Syntax is : public Calendar getCalendar()
Method returns the calendar associated with this date/time formatter.

Here is the code.
/**
 * @(#) GetCalendarDateFormat.java
 * A class representing use of method getCalendar() of DateFormat
class in java.text Package.
 * @Version  12-May-2008
 @author   Rose India Team
 */
import java.util.*;
import java.text.*;

class GetCalendarDateFormat {

    public static void main(String[] args) {

        // Create new Date object that will be initialized to the current date.
        Date date = new Date();
        System.out.println("Date  by  Date  class    : " + date.toString());

        // Create new DateFormat object that will returns default date/time.
        DateFormat dateFormat = DateFormat.getInstance();

        // getCalendar method call.
        Calendar calender = dateFormat.getCalendar();
        System.out.println("Calendar for this date format :\n" + calender);
    }
}

Output of the program.
 Date  by  Date  class    : Thu Jun 12 18:03:31 GMT+05:30 2008
Calendar for this date format :
java.util.GregorianCalendar[time=-1311333988000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,
zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,
transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=1928,MONTH=5,
WEEK_OF_YEAR=24,WEEK_OF_MONTH=3,DAY_OF_MONTH=12,DAY_OF_YEAR=164,DAY_OF_WEEK=3,
DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=6,HOUR_OF_DAY=18,MINUTE=3,SECOND=32,
MILLISECOND=0,ZONE_OFFSET=19800000,DST_OFFSET=0]

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US