Here you can find the source of getMonthForString(String monthStr, Locale locale)
Parameter | Description |
---|---|
monthStr | String to parse |
locale | Locale to use |
private static int getMonthForString(String monthStr, Locale locale)
//package com.java2s; /******************************************************************************* * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w ww . j av a 2s . co m*/ * emil.crumhorn@gmail.com - initial API and implementation *******************************************************************************/ import java.text.DateFormatSymbols; import java.util.Locale; public class Main { /** * Parses a string (representing a month) and returns it's corresponding * value as a Calendar month. This is used to parse MMM month dates * * @param monthStr * String to parse * @param locale * Locale to use * @return Month value or -1 if not found */ private static int getMonthForString(String monthStr, Locale locale) { DateFormatSymbols dfs = new DateFormatSymbols(locale); String[] months = dfs.getMonths(); for (int i = 0; i < months.length; i++) { if (months[i].toLowerCase(locale).startsWith(monthStr.toLowerCase(locale))) { return i + 1; } } return -1; } }