Java Month Get getMonth(String strDate)

Here you can find the source of getMonth(String strDate)

Description

get Month

License

LGPL

Declaration

public static String getMonth(String strDate) 

Method Source Code

//package com.java2s;
/**/*from w ww.j  av  a2 s. c  o m*/
 *
 * Methods Descrip:Converts a line of text into an array of lower case words
 * using a BreakIterator.wordInstance().
 * <p>
 *
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param text
 *            a String of text to convert into an array of words
 * @return text broken up into an array of words.
 *
 */

public class Main {

    public static String getMonth(String strDate) {
        String month = "";
        if (strDate != null && !strDate.equals("")) {
            strDate = strDate.trim();
            month = getElement(strDate.split("-"), 1);
        }
        if (!month.equals("") && month.length() > 1) {
            if (month.substring(0, 1).equals("0")) {
                month = month.substring(1, month.length());
            }
        }
        return month;
    }

    private static String getElement(String[] strs, int number) {
        String elemenet = "";
        if (strs != null) {
            int length = strs.length;
            if (number > length) {
                elemenet = strs[length];
            } else {
                elemenet = strs[number];
            }
        }
        return elemenet;
    }
}

Related

  1. getMonth(String pFormattedDate)
  2. getMonth(String quarters)
  3. getMonth(String sMonth)
  4. getMonth(String startTime)
  5. getMonth(String str_date)
  6. getMonth(String strDate)
  7. getMonth(String tempdat, Locale locale)
  8. getMonth1D()
  9. getMonthAdd(String operateDate, int flag)