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

StringgetLastDayOfCurMonth()
get Last Day Of Cur Month
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.DATE, 1);
calendar.roll(Calendar.DATE, -1);
SimpleDateFormat simpleFormate = new SimpleDateFormat("yyyy-MM-dd");
return simpleFormate.format(calendar.getTime()).trim();
StringgetLastDayOfLastMonth()
get Last Day Of Last Month
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.DAY_OF_MONTH, -1);
return format.format(cal.getTime());
DategetlastDayOfMonth()
getlast Day Of Month
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat(YYYYMMDDHHMMSS);
Calendar eCal = Calendar.getInstance();
eCal.setTime(date);
eCal.set(Calendar.DAY_OF_MONTH, 1);
eCal.add(Calendar.MONTH, 1);
eCal.add(Calendar.DATE, -1);
try {
...
StringgetLastdayofMonth()
get Lastdayof Month
Calendar c = Calendar.getInstance();
int totalday = c.getActualMaximum(Calendar.DAY_OF_MONTH);
c.set(Calendar.DAY_OF_MONTH, totalday);
System.out.println(c.getTime());
return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
StringgetLastDayOfMonth()
get Last Day Of Month
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
final int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
Date lastDate = calendar.getTime();
lastDate.setDate(lastDay);
return sdf2.format(lastDate);
StringgetLastDayOfMonth()
get Last Day Of Month
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar ca = Calendar.getInstance();
ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
String last = sdf.format(ca.getTime());
return last;
DategetLastDayOfMonth(Calendar c)
get Last Day Of Month
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH) + 1;
int day = 1;
if (month > 11) {
    month = 0;
    year = year + 1;
c.set(year, month, day - 1, 0, 0, 0);
...
StringgetLastDayOfMonth(Date currDate)
get Last Day Of Month
Calendar cal = Calendar.getInstance();
cal.setTime(currDate);
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, lastDay);
return getFormatDate(cal.getTime(), DATE_FORMAT);
DategetLastDayOfMonth(Date date)
get Last Day Of Month
Calendar calendar = Calendar.getInstance();
Date tempDate = (date == null ? new Date() : date);
calendar.setTime(tempDate);
calendar.set(Calendar.DATE, getMaxDayNum(tempDate));
calendar.set(Calendar.HOUR_OF_DAY, DEFALUT_HOUR_OF_DAY);
calendar.set(Calendar.MINUTE, DEFAULT_MINUTE);
calendar.set(Calendar.SECOND, DEFAULT_SECOND);
calendar.set(Calendar.MILLISECOND, 0);
...
DategetLastDayOfMonth(Date date)
get Last Day Of Month
date = addMonths(date, 1);
return getLastDayOfPreviousMonth(date);