GregorianCalendar: get(int a) : GregorianCalendar « java.util « Java by API






GregorianCalendar: get(int a)

 
/*
 * Output: 
2006
false
Month = 3
Week of year = 17
Week of month = 5
Day of year = 115
Day of week = 3 
 */

import java.util.Calendar;
import java.util.GregorianCalendar;

public class MainClass {

  public static void main(String args[]) {
    GregorianCalendar gc = new GregorianCalendar();
    int year = gc.get(Calendar.YEAR);
    System.out.println(year);
    System.out.println(gc.isLeapYear(year));
    System.out.println("Month = " + gc.get(Calendar.MONTH));
    System.out.println("Week of year = " + gc.get(Calendar.WEEK_OF_YEAR));
    System.out.println("Week of month = " + gc.get(Calendar.WEEK_OF_MONTH));
    System.out.println("Day of year = " + gc.get(Calendar.DAY_OF_YEAR));
    System.out.println("Day of week = " + gc.get(Calendar.DAY_OF_WEEK));
  }
}
           
         
  








Related examples in the same category

1.new GregorianCalendar()
2.new GregorianCalendar(int year, int month, int dayOfMonth)
3.new GregorianCalendar(Locale aLocale)
4.new GregorianCalendar(TimeZone zone, Locale aLocale)
5.GregorianCalendar: getTime()
6.GregorianCalendar: isLeapYear()
7.GregorianCalendar: roll(int field, boolean up)
8.GregorianCalendar: set(int field, int value)
9.GregorianCalendar: set(int year, int month, int date)
10.GregorianCalendar: setTime(Date date)