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

DategetCurrMonthFirstDay()
get Curr Month First Day
Calendar calendar = Calendar.getInstance();
Date d = new Date();
calendar.setTime(d);
calendar.set(Calendar.DATE, 1);
return calendar.getTime();
intgetDayOfMonth()
get Day Of Month
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.DAY_OF_MONTH);
intgetDaysInMonth(final Date date)
Returns the number of days in the month given a date
final GregorianCalendar c = gregorianCalendarThreadLocal.get();
c.setTime(date);
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.getActualMaximum(Calendar.DAY_OF_MONTH));
return c.get(Calendar.DAY_OF_MONTH);
intgetDaysOfMonth(Date date)
get Days Of Month
calendar.setTime(date);
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
intgetDaysOfMonth(Date date)
get Days Of Month
Calendar c = Calendar.getInstance();
c.setTime(date);
return c.getActualMaximum(5);
StringgetFirstDate(String base_month)
get First Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
ParsePosition pos1 = new ParsePosition(0);
base_month = base_month + "01";
java.util.Date FirstDate = sdf.parse(base_month, pos1);
return String.valueOf(sdf.format(FirstDate));
StringgetFirstDateOfCurMonth()
get First Date Of Cur Month
String curYearMonth = getCurYearMonth();
return curYearMonth + "-01";
DategetFirstDateOfMonth(Date theDate)
get First Date Of Month
Calendar c = new GregorianCalendar();
c.setTime(theDate);
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
...
DategetFirstday_Month(Date date, int months)
get Firstda Month
SimpleDateFormat df = new SimpleDateFormat(webFormat);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, months);
Date theDate = calendar.getTime();
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(theDate);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
...
StringgetFirstDayOfCurMonth()
get First Day Of Cur Month
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.DATE, 1);
SimpleDateFormat simpleFormate = new SimpleDateFormat("yyyy-MM-dd");
return simpleFormate.format(calendar.getTime()).trim();