Java Utililty Methods Month

List of utility methods to do Month

Description

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

Method

intgetMonthRange(String start, String end)
get Month Range
int range = 0;
try {
    String yearEnd = end.substring(0, 4);
    String monthEnd = end.substring(4);
    String yearStart = start.substring(0, 4);
    String monthStart = start.substring(4);
    range = (Integer.parseInt(yearEnd) - Integer.parseInt(yearStart)) * 12 + Integer.parseInt(monthEnd)
            - Integer.parseInt(monthStart) + 1;
...
String[]getMonths()
get Months
String months[] = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
return months;
intgetMonths(String strDateBegin, String strDateEnd)
get Months
try {
    int strOut;
    if (strDateBegin.equals("") || strDateEnd.equals("") || strDateBegin.length() != 6
            || strDateEnd.length() != 6) {
        strOut = 0;
    } else {
        int intMonthBegin = Integer.parseInt(strDateBegin.substring(0, 4)) * 12
                + Integer.parseInt(strDateBegin.substring(4, 6));
...
StringgetMonthTime(String allDate)
get Month Time
return allDate.substring(5, 16);
StringgetMonthToMonth(int month)
get Month To Month
String monthToMonth = "";
String[] months = { "(January-March)", "(April-June)", "(July-September)", "(October-December)" };
int index = month / 3;
monthToMonth = months[index];
return monthToMonth;
DoublegetMonthTotal(Double bsAmount, Double susAmount, Double changeRate)
Calculates the bsAmount(converted to dollars)+susAmount
Double res = null;
if (bsAmount != null) {
    res = bsAmount / changeRate;
if (susAmount != null) {
    if (res != null) {
        res += susAmount;
    } else {
...
StringgetNextMonth(String curYearMonth)
get Next Month
int year = Integer.parseInt(curYearMonth.substring(0, 4));
int month = Integer.parseInt(curYearMonth.substring(4));
if (month == 12) {
    year += 1;
    month = 1;
} else {
    month += 1;
StringBuffer strb = new StringBuffer().append(year);
if (month > 9)
    strb.append(month);
else
    strb.append("0").append(month);
return strb.toString();
StringgetNextMonth(String month)
get Next Month
int year = Integer.parseInt(month.substring(0, 4));
int mon = Integer.parseInt(month.substring(4, 6));
String nextmonth = "";
String nextyear = String.valueOf(year);
if (mon == 12) {
    nextmonth = "01";
    nextyear = String.valueOf(year + 1);
} else if (mon < 9) {
...
StringgetNextMonthSpe(String curYearMonth)
get Next Month Spe
curYearMonth = curYearMonth.replace("-", "");
String yearMonth = getNextMonth(curYearMonth);
return yearMonth.substring(0, 4) + "-" + yearMonth.substring(4);
StringgetPreMonth(String thisMonth)
get Pre Month
String yearMonth[] = thisMonth.split("-");
int month = Integer.parseInt(yearMonth[1]);
if (month > 1) {
    return yearMonth[0] + "-" + String.format("%02d", month - 1);
int year = Integer.parseInt(yearMonth[0]);
return (year - 1) + "-12";