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 boolean isHoliday(Calendar c) {
    final int week = c.get(Calendar.DAY_OF_WEEK);
    return week == Calendar.SUNDAY || week == Calendar.SATURDAY;
}

From source file:Main.java

public static boolean determineAskUserForStart(Calendar calendar) {
    if (calendar.get(Calendar.DAY_OF_WEEK) >= Calendar.WEDNESDAY) {
        return true;
    } else {/*  w w  w .  j  a v  a2s .c  om*/
        return false;
    }
}

From source file:Main.java

public static String toDateString(Calendar date) {
    int day = date.get(Calendar.DAY_OF_MONTH);
    int month = date.get(Calendar.MONTH);
    int year = date.get(Calendar.YEAR);
    return day + "/" + (month + 1) + "/" + year;
}

From source file:Main.java

public static int getHourOfDay(Calendar paramCalendar) {
    return paramCalendar.get(11);
}

From source file:Main.java

public static Integer getDay(Date date) {
    if (date == null)
        return 0;
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);// ww  w .j a va2 s .c o  m
    return cal.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static int getDateOfYear(Calendar paramCalendar) {
    return paramCalendar.get(6);
}

From source file:Main.java

public static int getMinute(Calendar paramCalendar) {
    return paramCalendar.get(12);
}

From source file:Main.java

public static int getYear(Calendar paramCalendar) {
    return paramCalendar.get(1);
}

From source file:Main.java

public static Integer getMonth(Date date) {
    if (date == null)
        return 0;
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);//from   w  ww .j ava2 s  .c  o m
    return cal.get(Calendar.MONTH);
}

From source file:Main.java

public static Integer getYear(Date date) {
    if (date == null)
        return 0;
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);/*ww  w. j  a v  a2 s  . c om*/
    return cal.get(Calendar.YEAR);
}