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:DayWeek.java

public static void main(String[] av) {
    //+/*from w w w .ja  va2s. c o  m*/
    Calendar c = Calendar.getInstance(); // today

    System.out.println("Year: " + c.get(Calendar.YEAR));
    System.out.println("Month: " + c.get(Calendar.MONTH));
    System.out.println("Day: " + c.get(Calendar.DAY_OF_MONTH));
    System.out.println("Day of week = " + c.get(Calendar.DAY_OF_WEEK));
    System.out.println("Day of year = " + c.get(Calendar.DAY_OF_YEAR));
    System.out.println("Week in Year: " + c.get(Calendar.WEEK_OF_YEAR));
    System.out.println("Week in Month: " + c.get(Calendar.WEEK_OF_MONTH));
    System.out.println("Day of Week in Month: " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
    System.out.println("Hour: " + c.get(Calendar.HOUR));
    System.out.println("AM or PM: " + c.get(Calendar.AM_PM));
    System.out.println("Hour (24-hour clock): " + c.get(Calendar.HOUR_OF_DAY));
    System.out.println("Minute: " + c.get(Calendar.MINUTE));
    System.out.println("Second: " + c.get(Calendar.SECOND));
    //-
}

From source file:co.com.runt.runistac.logica.TareasLogica.java

public static void main(String[] args) {
    Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, 30);
    System.out.println(c);
}

From source file:Main.java

public static boolean isInSameDay(Calendar cl1, Calendar cl2) {
    if (cl1.get(Calendar.DAY_OF_YEAR) == cl2.get(Calendar.DAY_OF_YEAR)
            && cl1.get(Calendar.YEAR) == cl2.get(Calendar.YEAR)) {
        return true;
    }/*w ww .jav  a  2 s.  c o  m*/
    return false;
}

From source file:Main.java

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

From source file:Main.java

public static Date yesterday() {
    return offsiteDate(new Date(), Calendar.DAY_OF_YEAR, -1);
}

From source file:Main.java

public static int getDayOfYear() {
    return Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
}

From source file:Main.java

public static int getDaysOfYear() {
    return new GregorianCalendar().get(Calendar.DAY_OF_YEAR);

}

From source file:Main.java

public static long getMinTimeStampForIgMedia() {
    Calendar rightNow = Calendar.getInstance();
    rightNow.add(Calendar.DAY_OF_YEAR, -2);

    return rightNow.getTimeInMillis() / 1000;
}

From source file:Main.java

private static boolean isSameDay(Calendar now, Calendar msg) {
    int nowDay = now.get(Calendar.DAY_OF_YEAR);
    int msgDay = msg.get(Calendar.DAY_OF_YEAR);

    return nowDay == msgDay;
}

From source file:Main.java

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