Source Code : Get method from GregorianCalendar
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Get method from GregorianCalendar
import java.util.Calendar;
import java.util.GregorianCalendar;
class GregorianCalendarDemo {
public static void main(String args[]) {
String months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec" };
int year;
GregorianCalendar gcalendar = new GregorianCalendar();
System.out.print("Date: ");
System.out.print(months[gcalendar.get(Calendar.MONTH)]);
System.out.print(" " + gcalendar.get(Calendar.DATE) + " ");
System.out.println(year = gcalendar.get(Calendar.YEAR));
System.out.print("Time: ");
System.out.print(gcalendar.get(Calendar.HOUR) + ":");
System.out.print(gcalendar.get(Calendar.MINUTE) + ":");
System.out.println(gcalendar.get(Calendar.SECOND));
if (gcalendar.isLeapYear(year)) {
System.out.println("The current year is a leap year");
} else {
System.out.println("The current year is not a leap year");
}
}
}
Thank with us