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

StringgetFirstDayOfCurrentMonth()
get First Day Of Current Month
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
return new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
StringgetFirstDayOfLastMonth()
get First Day Of Last Month
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.MONTH, -1);
cal.set(Calendar.DAY_OF_MONTH, 1);
return format.format(cal.getTime());
DategetfirstDayOfMonth()
getfirst Day Of Month
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat(YYYYMMDD);
Calendar sCal = Calendar.getInstance();
sCal.setTime(date);
sCal.add(Calendar.DAY_OF_MONTH, -(sCal.get(Calendar.DAY_OF_MONTH) - 1));
try {
    date = format.parse(format.format(sCal.getTime()));
} catch (ParseException e) {
...
DategetFirstDayOfMonth(Calendar c)
get First Day Of Month
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = 1;
c.set(year, month, day, 0, 0, 0);
return c.getTime();
StringgetFirstDayOfMonth(Date date)
get First Day Of Month
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DATE));
return date2String(cal.getTime());
DategetFirstDayOfMonth(Date date)
get First Day Of Month
if (null == date)
    return null;
return parserDate(getFirstDayStringOfMonth(date), format2);
DategetFirstDayOfMonth(Date date)
get First Day Of Month
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1);
return calendar.getTime();
DategetFirstDayOfMonth(Date date)
get First Day Of Month
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1);
return calendar.getTime();
DategetFirstDayOfMonth(Date date)
get First Day Of Month
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, 1);
return startOfDay(calendar.getTime());
LonggetFirstDayOfMonth(Long date)
get First Day Of Month
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
return cal.getTimeInMillis();
...