Java Month getMonths(String strDateBegin, String strDateEnd)

Here you can find the source of getMonths(String strDateBegin, String strDateEnd)

Description

get Months

License

Open Source License

Declaration

public static int getMonths(String strDateBegin, String strDateEnd) 

Method Source Code

//package com.java2s;

public class Main {

    public static int getMonths(String strDateBegin, String strDateEnd) {
        try {//from   www  . ja v  a 2s  .c o m
            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));
                int intMonthEnd = Integer.parseInt(strDateEnd.substring(0, 4)) * 12
                        + Integer.parseInt(strDateEnd.substring(4, 6));
                strOut = intMonthEnd - intMonthBegin;
            }
            return strOut;
        } catch (Exception e) {
            return 0;
        }
    }
}

Related

  1. getMonthLength(int year, int month)
  2. getMonthMaxDate(String str)
  3. getMonthOfNextQuarter(String yearAndMonth)
  4. getMonthRange(String start, String end)
  5. getMonths()
  6. getMonthTime(String allDate)
  7. getMonthToMonth(int month)
  8. getMonthTotal(Double bsAmount, Double susAmount, Double changeRate)
  9. getNextMonth(String curYearMonth)