Java Month Get getMonth(String sMonth)

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

Description

get Month

License

Apache License

Declaration

public static String getMonth(String sMonth) 

Method Source Code

//package com.java2s;
/*/*www.j a  v a  2  s  .co m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static String getMonth(String sMonth) {
        String sMonthLC = sMonth.toLowerCase();
        if (sMonthLC.startsWith("jan") || sMonthLC.startsWith("ge"))
            return "01";
        if (sMonthLC.startsWith("f"))
            return "02";
        if (sMonthLC.startsWith("mar"))
            return "03";
        if (sMonthLC.startsWith("ap"))
            return "04";
        if (sMonthLC.startsWith("may") || sMonthLC.startsWith("mag"))
            return "05";
        if (sMonthLC.startsWith("jun") || sMonthLC.startsWith("gi"))
            return "06";
        if (sMonthLC.startsWith("jul") || sMonthLC.startsWith("lu"))
            return "07";
        if (sMonthLC.startsWith("au") || sMonthLC.startsWith("ag"))
            return "08";
        if (sMonthLC.startsWith("s"))
            return "09";
        if (sMonthLC.startsWith("o"))
            return "10";
        if (sMonthLC.startsWith("n"))
            return "11";
        if (sMonthLC.startsWith("d"))
            return "12";
        return null;
    }
}

Related

  1. getMonth(String day)
  2. getMonth(String f)
  3. getMonth(String name)
  4. getMonth(String pFormattedDate)
  5. getMonth(String quarters)
  6. getMonth(String startTime)
  7. getMonth(String str_date)
  8. getMonth(String strDate)
  9. getMonth(String strDate)