Here you can find the source of monthStringToInteger(String month)
Parameter | Description |
---|---|
month | The month in String format (either 'Jan' or 'April') |
public static int monthStringToInteger(String month)
//package com.java2s; /**/*from www . ja v a2s . co m*/ * BACON (sdd.bacon@gmail.com) * * DateUtils - Provides an easy interface for getting/saving the current date. * * Copyright (c) 2010 * @author David Pizzuto, Seamus Reynolds, Matt Schoen, Michael Stark * All Rights Reserved * * @version 0.1, 04/02/10 * * http://code.google.com/p/bacon/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Fetches the numerical month value based on the given String representation. * * @param month The month in String format (either 'Jan' or 'April') * @return The month's integer value, or 0 if bad input is given. */ public static int monthStringToInteger(String month) { if (month.equalsIgnoreCase("Jan") || month.equalsIgnoreCase("January")) { return 0; } if (month.equalsIgnoreCase("Feb") || month.equalsIgnoreCase("February")) { return 1; } if (month.equalsIgnoreCase("Mar") || month.equalsIgnoreCase("March")) { return 2; } if (month.equalsIgnoreCase("Apr") || month.equalsIgnoreCase("April")) { return 3; } if (month.equalsIgnoreCase("May")) { return 4; } if (month.equalsIgnoreCase("Jun") || month.equalsIgnoreCase("June")) { return 5; } if (month.equalsIgnoreCase("Jul") || month.equalsIgnoreCase("July")) { return 6; } if (month.equalsIgnoreCase("Aug") || month.equalsIgnoreCase("August")) { return 7; } if (month.equalsIgnoreCase("Sep") || month.equalsIgnoreCase("September")) { return 8; } if (month.equalsIgnoreCase("Oct") || month.equalsIgnoreCase("October")) { return 9; } if (month.equalsIgnoreCase("Nov") || month.equalsIgnoreCase("November")) { return 10; } if (month.equalsIgnoreCase("Dec") || month.equalsIgnoreCase("December")) { return 11; } return -1; } }