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 boolean isSameDay(Calendar day1, Calendar day2) {
    return day1.get(Calendar.YEAR) == day2.get(Calendar.YEAR)
            && day1.get(Calendar.DAY_OF_YEAR) == day2.get(Calendar.DAY_OF_YEAR);
}

From source file:Main.java

public static boolean isSameDay(Calendar cal1, Calendar cal2) {
    return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
            && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)
            && cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static Calendar addYears(long time, int years) {
    return add(time, years, Calendar.YEAR);
}

From source file:Main.java

public static boolean equals(Calendar cal1, Calendar cal2) {
    int year1 = cal1.get(Calendar.YEAR);
    int dayOfYear1 = cal1.get(Calendar.DAY_OF_YEAR);
    int year2 = cal2.get(Calendar.YEAR);
    int dayOfYear2 = cal2.get(Calendar.DAY_OF_YEAR);
    return year1 == year2 && dayOfYear1 == dayOfYear2;
}

From source file:Main.java

static int year() {
    return (new GregorianCalendar()).get(Calendar.YEAR);
}

From source file:Main.java

public static String getTodaysDate() {
    Calendar c = Calendar.getInstance();
    return c.get(Calendar.YEAR) + "-0" + String.valueOf(c.get(Calendar.MONTH) + 1) + "-"
            + c.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static boolean isInSameDay(Calendar calendar1, Calendar calendar2) {
    return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
            && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH)
            && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static boolean isSameDay(Calendar a, Calendar b) {
    boolean res = false;
    if (a.get(Calendar.YEAR) == b.get(Calendar.YEAR)
            && a.get(Calendar.DAY_OF_YEAR) == b.get(Calendar.DAY_OF_YEAR)) {
        res = true;/*from  www  .j a  va2  s  .  c  o m*/
    }
    return res;
}

From source file:Main.java

public static boolean isSameDate(Calendar calendar1, Calendar calendar2) {
    if (calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
            && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH)
            && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH)) {
        return true;
    } else {//from  www .  j  av  a 2 s  . c o  m
        return false;
    }
}

From source file:Main.java

public static String getCurrentData() {
    Calendar c = Calendar.getInstance();
    return "" + c.get(Calendar.YEAR) + c.get(Calendar.MONTH) + c.get(Calendar.DAY_OF_MONTH);
}