Example usage for java.util Calendar YEAR

List of usage examples for java.util Calendar YEAR

Introduction

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

Prototype

int YEAR

To view the source code for java.util Calendar YEAR.

Click Source Link

Document

Field number for get and set indicating the year.

Usage

From source file:Main.java

public static void main(String[] args) {
    Calendar old = Calendar.getInstance();
    old.set(Calendar.YEAR, 2990);
    Calendar now = Calendar.getInstance();
    System.out.println("Is old before now ? : " + old.before(now));

}

From source file:Main.java

public static void main(String[] args) {

    Calendar future = Calendar.getInstance();
    future.set(Calendar.YEAR, 3010);

    Calendar now = Calendar.getInstance();

    System.out.println("Is futureCal after now ? : " + future.after(now));
}

From source file:Main.java

public static void main(String[] args) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, 2007);
    cal.set(Calendar.DAY_OF_YEAR, 180);

    System.out.println("Calendar date is: " + cal.getTime());

    int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);

    System.out.println("Calendar day of month: " + dayOfMonth);

    int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);

    System.out.println("Calendar day of week: " + dayOfWeek);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar futureCal = Calendar.getInstance();
    futureCal.set(Calendar.YEAR, 3000);
    Calendar now = Calendar.getInstance();
    System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE) + "-"
            + now.get(Calendar.YEAR));

    System.out.println("Is futureCal after now ? : " + futureCal.after(now));
}

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));
}

From source file:Main.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2007);
    calendar.set(Calendar.DAY_OF_YEAR, 180);

    // See the full information of the calendar object.
    System.out.println(calendar.getTime().toString());

    // Get the weekday and print it
    int weekday = calendar.get(Calendar.DAY_OF_WEEK);
    System.out.println("Weekday: " + weekday);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int year = 2004;
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    // /*  ww w  .j  a va  2s.  com*/
    System.out.println("Current Year is : " + now.get(Calendar.YEAR));
    // month start from 0 to 11
    System.out.println("Current Month is : " + (now.get(Calendar.MONTH) + 1));
    System.out.println("Current Date is : " + now.get(Calendar.DATE));
}

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = Calendar.getInstance();

    // print the minimum value for years
    int min = cal.getMinimum(Calendar.YEAR);
    System.out.println("Minimum Years: " + min);
}

From source file:Main.java

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

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, 2000);
    Date d2 = cal.getTime();/*from  w ww  .j a v a 2 s.c  o m*/

    System.out.println("First Date : " + d1);
    System.out.println("Second Date : " + d2);
    System.out.println("Is second date after first ? : " + d2.after(d1));
}