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 int getDay(Calendar c) {
    return c.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static int getMinute(Calendar calendar) {
    return calendar.get(Calendar.MINUTE);
}

From source file:Main.java

public static int getYear(Calendar calendar) {
    return calendar.get(Calendar.YEAR);
}

From source file:Main.java

public static String formatNoaaForCalendar(Calendar c) {
    return "" + c.get(Calendar.YEAR) + "-" + String.format("%02d", (c.get(Calendar.MONTH) + 1)) + "-"
            + String.format("%02d", c.get(Calendar.DATE));
}

From source file:Main.java

public static boolean isDisturbTime(Calendar c) {
    int hours = c.get(Calendar.HOUR_OF_DAY);
    return hours >= 23 | hours < 6;
}

From source file:Main.java

private static void prepareCalendarNoSunday(Calendar calendar) {
    if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.SUNDAY) {
        calendar.add(Calendar.DATE, 1);
    }/*from w ww  .  j  a  v  a  2 s  .  c om*/
}

From source file:Main.java

public static int getDay(Calendar calendar) {
    return calendar.get(DATE);
}

From source file:Main.java

public static int getDayOfWeek(Calendar calendar) {
    return calendar.get(DAY_OF_WEEK);
}

From source file:Main.java

public static String calendar2str(Calendar c) {
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH) + 1;
    int day = c.get(Calendar.DAY_OF_MONTH);
    return year + "-" + month + "-" + day;
}

From source file:Main.java

public static int getYear(Calendar c) {
    return c.get(Calendar.YEAR);
}