Java Utililty Methods Month Convert

List of utility methods to do Month Convert

Description

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

Method

StringcreateFutureDate(int days, int months)
Creates a new date/time string presented in the SIP2 format "yyyyMMdd HHmmss" by adding the given number of days and months to the current date.
Calendar date = Calendar.getInstance();
date.setTime(new Date());
date.add(Calendar.DATE, days);
date.add(Calendar.MONTH, months);
return toSipDateTime(date.getTime());
intdifferenceMonth(String strDate1, String strDate2)
difference Month
Date date1 = DateFormat.getDateInstance().parse(strDate1);
Date date2 = DateFormat.getDateInstance().parse(strDate2);
return differenceMonth(date1, date2);
BooleanisCurMonth(String month)
is Cur Month
SimpleDateFormat daytime = new SimpleDateFormat("yyyyMM");
Calendar calendar = Calendar.getInstance();
String curMonth = daytime.format(calendar.getTime());
return month.equals(curMonth);
Stringmonth()
month
return now("MM");
Stringmonth(Date date, Locale locale)
month
Calendar c = Calendar.getInstance(locale);
c.setTime(date);
DateFormatSymbols symbols = new DateFormatSymbols(locale);
return symbols.getMonths()[c.get(Calendar.MONTH)];
Stringmonth2String(Date date)
month String
DateFormat format1 = new SimpleDateFormat("M.dd");
return format1.format(date);
StringmonthAgo()
month Ago
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, -30);
return convertDate2String5(cal.getTime());
intmonthConvertToNumber(String str)
month Convert To Number
switch (str) {
case "Jan":
    return 1;
case "Feb":
    return 2;
case "Mar":
    return 3;
case "Apr":
...
StringmonthformMatDate(Date date)
monthform Mat Date
return smdf.format(date);
StringmonthIndexAsString(Integer index, Integer offset)
month Index As String
if (index == null) {
    return "";
index = index - offset + 1;
String result = "";
SimpleDateFormat numberFormat = new SimpleDateFormat("MM");
SimpleDateFormat stringFormat = new SimpleDateFormat("MMMM", Locale.US);
try {
...