Example usage for java.util Calendar DATE

List of usage examples for java.util Calendar DATE

Introduction

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

Prototype

int DATE

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

Click Source Link

Document

Field number for get and set indicating the day of the month.

Usage

From source file:Main.java

public static Date addDays(Date date, int days) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);//from  www .java 2  s .  c  o m
    cal.add(Calendar.DATE, days); //minus number would decrement the days
    return cal.getTime();
}

From source file:Main.java

public static Date addDay(Date date, int n) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);//  ww w .  j a  va  2s  .  c  om
    cal.add(Calendar.DATE, n);
    return cal.getTime();

}

From source file:DateUtils.java

public static Date getYesterday() {
    GregorianCalendar yesterday = new GregorianCalendar();
    yesterday.add(Calendar.DATE, -1);
    return yesterday.getTime();
}

From source file:Main.java

public static int getCurrentMonthDay() {
    // calendar.getActualMaximum(Calendar.DAY_OF_MONTH),
    Calendar a = Calendar.getInstance();
    a.set(Calendar.DATE, 1);
    a.roll(Calendar.DATE, -1);/*  w  w  w.  ja  v  a  2s .c  om*/
    int maxDate = a.get(Calendar.DATE);
    return maxDate;
}

From source file:Main.java

public static void setDateTime(long timeStamp, Calendar currentCalender, int i) {
    currentCalender.setTimeInMillis(timeStamp);
    currentCalender.set(Calendar.DATE, 1);
    currentCalender.set(Calendar.HOUR_OF_DAY, 0);
    currentCalender.set(Calendar.MINUTE, 0);
    currentCalender.set(Calendar.SECOND, 0);
    currentCalender.set(Calendar.MILLISECOND, 0);
    currentCalender.add(Calendar.DATE, i);
}

From source file:Main.java

public static int getDayOfMonth(int y, int m) {
    Calendar cal = Calendar.getInstance();
    cal.set(y, m - 1, 1);//from w  w  w  .j a va 2s . c o m
    int dateOfMonth = cal.getActualMaximum(Calendar.DATE);
    return dateOfMonth;
}

From source file:Main.java

public static Calendar getNotificationCalendarNextDate(int hour, int minute) {
    Calendar currentCalendar = Calendar.getInstance();
    currentCalendar.add(Calendar.DATE, 1);
    currentCalendar.set(Calendar.HOUR_OF_DAY, hour);
    currentCalendar.set(Calendar.MINUTE, minute);
    return currentCalendar;

}

From source file:Main.java

public static int getDayOfMaonth(int y, int m) {
    Calendar cal = Calendar.getInstance();
    cal.set(y, m - 1, 1);//from  w  ww. j a v a  2  s. co  m
    int dateOfMonth = cal.getActualMaximum(Calendar.DATE);
    return dateOfMonth;
}

From source file:Main.java

public static Date getYesterdayDate() {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -1);
    return cal.getTime();
}

From source file:Main.java

public static Date getFirstDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);/*from  w  ww  .ja v  a  2  s . c o  m*/
    calendar.set(Calendar.DATE, 1);
    return calendar.getTime();
}