Example usage for java.util Calendar DAY_OF_YEAR

List of usage examples for java.util Calendar DAY_OF_YEAR

Introduction

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

Prototype

int DAY_OF_YEAR

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

Click Source Link

Document

Field number for get and set indicating the day number within the current year.

Usage

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

private static boolean isTheDayBeforeYesterDay(Calendar now, Calendar msg) {
    int nowDay = now.get(Calendar.DAY_OF_YEAR);
    int msgDay = msg.get(Calendar.DAY_OF_YEAR);
    return (nowDay - msgDay) == 2;
}

From source file:Main.java

public static Date getTimeYearNext() {
    calendar.add(Calendar.DAY_OF_YEAR, 183);
    return calendar.getTime();
}

From source file:Main.java

public static Calendar addDayToDate(Calendar dataInicio, int quantidade) {
    Calendar dataFim = (Calendar) dataInicio.clone();
    dataFim.add(Calendar.DAY_OF_YEAR, quantidade);
    return dataFim;
}

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 int getDayOfYear() {
    Calendar c = Calendar.getInstance();
    c.setTime(new Date());
    int year = c.get(Calendar.DAY_OF_YEAR);
    return year;//w  w  w .  ja v a2 s .  co  m
}

From source file:Main.java

public static int dayOfYear() {
    return calendar().get(Calendar.DAY_OF_YEAR);
}

From source file:Main.java

public static int getDaysLeftInYear() {
    Calendar calendar = Calendar.getInstance();
    return calendar.getActualMaximum(Calendar.DAY_OF_YEAR) - calendar.get(Calendar.DAY_OF_YEAR);
}

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 v  a2 s . c  om*/
    }
    return res;
}

From source file:Main.java

public static Date dateAddDays(Date date, int days) {

    Calendar cal = Calendar.getInstance();
    cal.setTime(date);//from  w  w w .ja v a  2s.co  m
    cal.add(Calendar.DAY_OF_YEAR, days);
    return cal.getTime();
}