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 Calendar GetLastMonthRightRange(Calendar today) {
    Calendar calendar = (Calendar) today.clone();
    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 Calendar GetLastMonthLeftRange(Calendar today) {
    Calendar calendar = (Calendar) today.clone();
    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.MONTH, -1);
    calendar.add(Calendar.MINUTE, 0);
    return calendar;
}

From source file:Main.java

public static Calendar getCalendarSetToFirstDayOfNextMonth(Calendar currentMonth) {
    currentMonth.add(Calendar.MONTH, 1);
    currentMonth.set(Calendar.DAY_OF_MONTH, currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH));
    return currentMonth;
}

From source file:Main.java

public static int getDayOfMonth(Date date) {
    return getCalendar(date).get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static String dataHoje() {
    Integer dia, mes, ano;//w  ww .j  av a 2s . c o m
    Calendar calendario = Calendar.getInstance();
    dia = calendario.get(Calendar.DAY_OF_MONTH);
    mes = calendario.get(Calendar.MONTH);
    ano = calendario.get(Calendar.YEAR);
    return dia + "/" + (mes + 1) + "/" + ano;
}

From source file:Main.java

public static int getCurrentDay() {
    Calendar calendar = Calendar.getInstance();
    return calendar.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static String getCurrentData() {
    Calendar c = Calendar.getInstance();
    return "" + c.get(Calendar.YEAR) + c.get(Calendar.MONTH) + c.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static Calendar getCalendarSetToLastDayOfPreviousMonth(Calendar currentMonth) {
    currentMonth.add(Calendar.MONTH, -1);
    currentMonth.set(Calendar.DAY_OF_MONTH, currentMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
    return currentMonth;
}

From source file:Main.java

public static Calendar addDaysIfBefore(Calendar date, Calendar dateBefore, int daysToAdd) {
    while (date.before(dateBefore)) {
        date.add(Calendar.DAY_OF_MONTH, daysToAdd);
    }//from  w  w w.ja va  2  s.c o  m

    return date;
}

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;
}