Java Month Name Get getMonthByName(String monthName)

Here you can find the source of getMonthByName(String monthName)

Description

Get the Month by Name

License

Apache License

Parameter

Parameter Description
monthName a parameter

Declaration

public static int getMonthByName(String monthName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public final static String[] MONTHS = new String[] { "january", "february", "march", "april", "may", "june",
            "july", "august", "september", "october", "november", "december" };

    /**/*from w  w w .java2  s.  c o m*/
     * Get the Month by Name
     * 
     * @param monthName
     * @return
     */
    public static int getMonthByName(String monthName) {
        // fiscalStartsList = null;
        for (int i = 0; i < MONTHS.length; i++) {
            if (monthName.toLowerCase().equals(MONTHS[i])) {
                return i;
            }
        }
        return 0;
    }
}

Related

  1. createDaemonThread(Runnable runnable, String threadName)
  2. getDutchMonthName(int monthNumber)
  3. getMonth(boolean name)
  4. getMonth(String monthName)
  5. getMonthFromMonthName(String name)
  6. getMonthName()
  7. getMonthName(Date date)
  8. getMonthName(int index)