Java Utililty Methods Month Format

List of utility methods to do Month Format

Description

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

Method

StringgetAfterByNMonth(String format, int months)
get After By N Month
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.MONTH, months);
Date newDate = c.getTime();
return formatDate(newDate, format);
StringgetCurrMonthFirstDaySlashFormat()
get Curr Month First Day Slash Format
Calendar calendar = Calendar.getInstance();
Date d = new Date();
calendar.setTime(d);
calendar.set(Calendar.DATE, 1);
return dateSlashFormat(calendar.getTime());
ListgetDisplayMonth(Date time, int monthBefore, int monthAfter, SimpleDateFormat format)
get Display Month
ArrayList result = new ArrayList();
Calendar calendar = Calendar.getInstance();
if (null != time) {
    calendar.setTimeInMillis(time.getTime());
SimpleDateFormat tmpformat = format;
if (null == tmpformat) {
    tmpformat = new SimpleDateFormat("yyyy/MM");
...
StringgetFirstDayOfNextMonth(String dateFormat)
get First Day Of Next Month
String strDate = null;
try {
    Calendar c = new GregorianCalendar();
    SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(dateFormat);
    c.roll(Calendar.MONTH, 1);
    c.set(GregorianCalendar.DAY_OF_MONTH, 1);
    strDate = mSimpleDateFormat.format(c.getTime());
} catch (Exception e) {
...
StringgetFormatCurMonthAsYYYYMM()
get Format Cur Month As YYYYMM
return yyyymm.format(currentDate());
StringgetLastYearMonthYYYYMM()
get Last Year Month YYYYMM
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
SimpleDateFormat simpleFormate = new SimpleDateFormat("yyyyMM");
return simpleFormate.format(calendar.getTime()).trim();
StringgetMonthFormat(String dateString)
get Month Format
int start = 0;
int to = dateString.lastIndexOf(".");
return dateString.substring(start, to);
DategetUpMonthDate(String date, String dateFormat)
get Up Month Date
Calendar c = new GregorianCalendar();
c.setTime(strToDate(date, dateFormat));
c.add(Calendar.MONTH, -1);
return c.getTime();
StringgetYesterMonthDate(String format)
get Yester Month Date
Calendar day = Calendar.getInstance();
day.add(Calendar.MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(day.getTime());
intmonthsBetween(String from, String to, String format)
months Between
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
Calendar calendar = Calendar.getInstance(Locale.UK);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
Date fromDate = null;
Date toDate = null;
try {
    fromDate = formatter.parse(from);
...