Java Utililty Methods Month Day

List of utility methods to do Month Day

Description

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

Method

StringgetFirstDayOfNextMonth()
get First Day Of Next Month
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, +1);
int firstDay = cal.getMinimum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, firstDay);
return getFormatDate(cal.getTime(), DATE_FORMAT);
StringgetFirstDayStringOfMonth(Date date)
get First Day String Of Month
if (null == date)
    return null;
return getFormateDateString(date, format2);
StringgetFirstDayStrOfMonth(Date date)
get First Day Str Of Month
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
return formatDate2Str(calendar.getTime());
DategetLastMonthDay()
get Last Month Day
String pattern = "yyyy-MM-dd";
Calendar cd = Calendar.getInstance();
cd.add(Calendar.MONTH, -1);
String newTime = String.valueOf(cd.get(Calendar.YEAR)) + "-" + String.valueOf(cd.get(Calendar.MONTH) + 1)
        + "-" + String.valueOf("01");
return convertStringToDate(newTime, pattern);
DategetLastMonthLastDate()
get Last Month Last Date
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
int max = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, max);
return calendar.getTime();
StringgetLastMonthLastDay()
get Last Month Last Day
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, 0);
return sdf.format(c.getTime());
StringgetLastMonthLastDay()
get Last Month Last Day
Calendar cal = Calendar.getInstance();
cal.setTime(cal.getTime());
cal.add(Calendar.MONTH, -1);
SimpleDateFormat daytime = new SimpleDateFormat("yyyyMMdd");
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
return daytime.format(cal.getTime());
StringgetLastMothStart()
get Last Moth Start
Calendar c = getCurCalendar();
c.add(Calendar.MONTH, -1);
c.set(Calendar.DAY_OF_MONTH, 1);
return formartRandomDate(c.getTime(), "yyyy-MM-dd");
DateGetLastWorkDayofMonth(String strDateStart)
Get Last Work Dayof Month
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date_start = sdf.parse(strDateStart);
Calendar cal_start = Calendar.getInstance();
cal_start.setTime(date_start);
int dayOfWeek = cal_start.get(Calendar.DAY_OF_WEEK) - 1;
Date a = new Date();
if (dayOfWeek == 1) {
    a = AddDate(date_start, -3);
...
DategetMonthDay(int year, int month)
get Month Day
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, lastDay);
return cal.getTime();