Java implementation of Calendar class
KW.java
import java.util.Calendar;
class KW
{
    public static void main(String args[])
    {
        Calendar c=Calendar.getInstance();
        System.out.println("———————————————————————————————————————————");
        System.out.println("Java implementation of Calendar class");
        System.out.println("———————————————————————————————————————————");
        System.out.println("Year          | "+c.get(Calendar.YEAR));
        System.out.println("Month         | "+c.get(Calendar.MONTH));
        System.out.println("Day of Month  | "+c.get(Calendar.DAY_OF_MONTH));
        System.out.println("Day of Week   | "+c.get(Calendar.DAY_OF_WEEK)); 
        System.out.println("Week of Month | "+c.get(Calendar.WEEK_OF_MONTH));
        System.out.println("DOW in Month  | "+c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
        System.out.println("Hour          | "+c.get(Calendar.HOUR));
        System.out.println("Minute        | "+c.get(Calendar.MINUTE));
        System.out.println("Seconds       | "+c.get(Calendar.SECOND));
        System.out.println("Time AM-0/PM-1| "+c.get(Calendar.AM_PM));
        System.out.println("———————————————————————————————————————————");
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Java implementation of Calendar class ——————————————————————————————————————————— Year | 2019 Month | 3 Day of Month | 28 Day of Week | 1 Week of Month | 5 DOW in Month | 4 Hour | 11 Minute | 48 Seconds | 58 Time AM-0/PM-1| 0 ——————————————————————————————————————————— kodingwindow@kw:~$
What Next?
Java Methods
Advertisement