Java Utililty Methods Day of Month

List of utility methods to do Day of Month

Description

The list of methods to do Day of Month are organized into topic(s).

Method

DategetFirstDayOfMonth(Date date)
get First Day Of Month
Calendar calender = Calendar.getInstance();
calender.setTime(date);
calender.set(Calendar.DAY_OF_MONTH, calender.getActualMinimum(Calendar.DAY_OF_MONTH));
setStartTimeOfDay(calender);
return calender.getTime();
DategetFirstDayOfMonth(Date date)
get First Day Of Month
Calendar result = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, date.getYear() + 1900);
calendar.set(Calendar.MONTH, date.getMonth());
calendar.set(Calendar.DATE, date.getDate());
result.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
result.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
...
java.util.DategetFirstDayOfMonth(java.util.Date date)
getFirstDayOfMonth: returns the first day of the given dates month
date = truncateToDay(date);
if (date != null) {
    java.util.Calendar c = java.util.Calendar.getInstance(Locale.GERMANY);
    c.setTime(date);
    c.set(Calendar.DAY_OF_MONTH, 1);
    return c.getTime();
} else {
    return null;
...
DategetFirstMiddleDayOfMonth(Date date)
get First Middle Day Of Month
Calendar todayCalendar = Calendar.getInstance();
todayCalendar.setTime(date);
Calendar firstMiddleDayOfmonthCalendar = Calendar.getInstance();
firstMiddleDayOfmonthCalendar.set(todayCalendar.get(Calendar.YEAR), todayCalendar.get(Calendar.MONTH), 16,
        0, 0, 0);
return firstMiddleDayOfmonthCalendar.getTime();
IntegergetFistDayOfMonth(Date date)
get Fist Day Of Month
Integer intDate = getIntDate(date);
int year = intDate / 10000;
int month = intDate % 10000 / 100;
return getIntDate(newCalendar(year, month, 1));
DategetFromDate(boolean invoiceSearchFromFirstDayOfMonth)
get From Date
if (invoiceSearchFromFirstDayOfMonth) {
    Calendar calendar = Calendar.getInstance();
    int month = calendar.get(Calendar.MONTH);
    calendar.set(Calendar.MONTH, month - 6);
    calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
...
StringgetLastDateOfCurMonth()
get Last Date Of Cur Month
String curYearMonth = getCurYearMonth();
Calendar calendar = Calendar.getInstance();
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
return curYearMonth + "-" + maxDay;
intgetLastDay(int year, int month)
get Last Day
int day = 0;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
...
StringgetLastDayByMonthWeek(int year, int month, int week)
get Last Day By Month Week
DateFormat df = new SimpleDateFormat("yyyy-MM-dd ");
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.WEEK_OF_MONTH, week);
int firstDayofweek = c.getFirstDayOfWeek();
int lastDayofweek = firstDayofweek + 6;
Calendar c2 = Calendar.getInstance();
...
intgetLastDayInMonth(int year, int month)
get Last Day In Month
int lLastDay = -1;
switch (month) {
case 0: 
case 2: 
case 4: 
case 6: 
case 7: 
case 9: 
...