Here you can find the source of getMonth(String monthName)
Parameter | Description |
---|---|
monthName | a parameter |
public static int getMonth(String monthName)
//package com.java2s; import java.text.DateFormatSymbols; public class Main { /**/*from ww w .ja v a2 s . c om*/ * Returns the index of month name provided. * Indexes start from 0. i.e. January -> 0 * @param monthName * @return index of month */ public static int getMonth(String monthName) { String[] months = getMonths(); int month = 0; for (int i = 0; i < months.length; i++) { if (monthName.equals(months[i])) { month = i; } } return month; } /** * Returns all months in a string array. * Indexes start from 0. i.e. 0 -> January * @return months */ public static String[] getMonths() { return new DateFormatSymbols().getMonths(); } }