Java Program that explain the Gregorian calendar class and display current year, current month, current date and also test if is a leap year or not.
Programimport java.util.*;
class grCalander
{
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));
}
}
No comments:
Post a Comment