Datasets:

ArXiv:
License:
File size: 1,214 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.*;
public class GregCal {
      public static void main(String args[]) {
	      String months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", 
	         "Oct", "Nov", "Dec"};
	      
	      int year;
	      // Create a Gregorian calendar initialized
	      // with the current date and time in the
	      // default locale and timezone.
	      
	      GregorianCalendar gcalendar = new GregorianCalendar();
	      
	      // Display current time and date information.
	      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));

	      // Test if the current year is a leap year
	      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 !");
	      }
	   }
	}