Example usage for java.util Calendar DAY_OF_MONTH

List of usage examples for java.util Calendar DAY_OF_MONTH

Introduction

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

Prototype

int DAY_OF_MONTH

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

Click Source Link

Document

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

Usage

From source file:Main.java

public static int getDayOfMonth(int offset) {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MONTH, offset);
    return calendar.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static int dayOfMonth() {
    return calendar().get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static long getStartOfCurrentMonth() {
    Calendar calendar = getCurrentCalendar();
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    return calendar.getTimeInMillis();
}

From source file:Util.java

public static int getDayOfMonthFromDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);//from   w w  w  .  j  a  v a 2 s .  c o  m
    return calendar.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static String getDayOfMonth(Date date, boolean withZeroFill) {
    Calendar calendar = getCalendar(date);
    String day = (calendar.get(Calendar.DAY_OF_MONTH)) + "";
    return (day.length() == 1 && withZeroFill) ? ("0" + day) : day;
}

From source file:Main.java

public static boolean isNationalDay() {
    Calendar calendar = Calendar.getInstance();
    int month = calendar.get(Calendar.MONTH) + 1;
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    if (month == 10 && day <= 7) {
        return true;
    }/* ww w .  j ava 2s .  c  om*/
    return false;
}

From source file:Main.java

public static boolean isCurrentDate(Calendar comparedDate) {

    Calendar cal = Calendar.getInstance();
    int[] comparedElements = { Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH };
    for (int elem : comparedElements) {
        if (cal.get(elem) != comparedDate.get(elem)) {
            return false;
        }//  w  w  w.  j  a v  a2 s .  c o  m
    }

    return true;
}

From source file:Main.java

public static Date getPreDay(Date presentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(presentDate);/*ww  w  .  j  a v a 2s  .c  o  m*/
    calendar.add(Calendar.DAY_OF_MONTH, -1);
    presentDate = calendar.getTime();
    return presentDate;
}

From source file:Main.java

public static Calendar GetThisYearLeftRange(Calendar today) {
    Calendar calendar = (Calendar) today.clone();
    calendar.set(Calendar.MONTH, 0);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    calendar.add(Calendar.MINUTE, 0);
    return calendar;
}

From source file:Main.java

public static Date getNextDay(Date presentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(presentDate);/*from  w w w . j a  v  a 2  s . c o m*/
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    presentDate = calendar.getTime();
    return presentDate;
}