Example usage for java.util Calendar get

List of usage examples for java.util Calendar get

Introduction

In this page you can find the example usage for java.util Calendar get.

Prototype

public int get(int field) 

Source Link

Document

Returns the value of the given calendar field.

Usage

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.MILLISECOND));

}

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.DST_OFFSET));

}

From source file:Main.java

public static void main(String[] args) {

    Calendar now = Calendar.getInstance();

    System.out.println(now.get(Calendar.DATE));

}

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.ZONE_OFFSET));

}

From source file:Main.java

public static void main(String[] args) {
    Calendar cal = new GregorianCalendar(1999, 1, 1);
    Calendar now = new GregorianCalendar();
    int res = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
    if ((cal.get(Calendar.MONTH) > now.get(Calendar.MONTH))
            || (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH)
                    && cal.get(Calendar.DAY_OF_MONTH) > now.get(Calendar.DAY_OF_MONTH))) {
        res--;//www .j a  v  a 2  s.  com
    }
    System.out.println(res);
}

From source file:Main.java

public static void main(String[] args) {

    Calendar now = Calendar.getInstance();

    System.out.println((now.get(Calendar.MONTH) + 1));

}

From source file:Main.java

public static void main(String[] args) {
    String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September",
            "October", "November", "December" };

    Calendar cal = Calendar.getInstance();
    String month = months[cal.get(Calendar.MONTH)];
    System.out.println("Month name: " + month);
}

From source file:Main.java

public static void main(String[] args) {
    String[] monthName = { "January", "February", "March", "April", "May", "June", "July", "August",
            "September", "October", "November", "December" };

    Calendar cal = Calendar.getInstance();
    String month = monthName[cal.get(Calendar.MONTH)];

    System.out.println("Month name: " + month);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar cal = Calendar.getInstance();
    int day = cal.get(Calendar.DATE);
    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int dow = cal.get(Calendar.DAY_OF_WEEK);
    int dom = cal.get(Calendar.DAY_OF_MONTH);
    int doy = cal.get(Calendar.DAY_OF_YEAR);

    System.out.println("Current Date: " + cal.getTime());
    System.out.println("Day: " + day);
    System.out.println("Month: " + month);
    System.out.println("Year: " + year);
    System.out.println("Day of Week: " + dow);
    System.out.println("Day of Month: " + dom);
    System.out.println("Day of Year: " + doy);
}

From source file:MainClass.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();

    System.out.println(calendar.get(Calendar.YEAR));
    System.out.println(calendar.get(Calendar.MONTH));
    System.out.println(calendar.get(Calendar.DATE));
    System.out.println(calendar.get(Calendar.HOUR));
    System.out.println(calendar.get(Calendar.MINUTE));
    System.out.println(calendar.get(Calendar.SECOND));
    System.out.println(calendar.get(Calendar.MILLISECOND));
}