Java Month monthAlphaToNum(String str)

Here you can find the source of monthAlphaToNum(String str)

Description

Month string to number

License

Open Source License

Parameter

Parameter Description
str month in string

Return

month in number

Declaration

private static String monthAlphaToNum(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from www  . j  ava 2 s  . co m*/
     * Month string to number
     * @param str month in string
     * @return month in number
     */
    private static String monthAlphaToNum(String str) {
        str = str.toLowerCase();
        if (str.equals("jan") || str.equals("january")) {
            return "01";
        } else if (str.equals("feb") || str.equals("february")) {
            return "02";
        } else if (str.equals("mar") || str.equals("march")) {
            return "03";
        } else if (str.equals("apr") || str.equals("april")) {
            return "04";
        } else if (str.equals("may")) {
            return "05";
        } else if (str.equals("jun") || str.equals("june")) {
            return "06";
        } else if (str.equals("jul") || str.equals("july")) {
            return "07";
        } else if (str.equals("aug") || str.equals("august")) {
            return "08";
        } else if (str.equals("sep") || str.equals("september")) {
            return "09";
        } else if (str.equals("oct") || str.equals("october")) {
            return "10";
        } else if (str.equals("nov") || str.equals("november")) {
            return "11";
        } else if (str.equals("dec") || str.equals("december")) {
            return "12";
        }
        return null;
    }
}

Related

  1. maxLengthOfMonth(int month)
  2. MONTH(int mh)
  3. month2int(String month)
  4. month2second(int month)
  5. month2String(int month)
  6. monthDiff(String beforeTime, String endTime)
  7. monthFromDateValue(long x)
  8. monthLength(int year, int month)
  9. monthMillis(int year, int monthNum)