Java Month returnMonth(String month)

Here you can find the source of returnMonth(String month)

Description

return Month

License

Open Source License

Declaration

public static int returnMonth(String month) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int returnMonth(String month) {
        if (month.toLowerCase().equals("jan")) {
            return 0;
        }//from  w w  w.  ja  va2s  . c  o  m

        if (month.toLowerCase().equals("feb")) {
            return 1;
        }

        if (month.toLowerCase().equals("mar")) {
            return 2;
        }

        if (month.toLowerCase().equals("apr")) {
            return 3;
        }

        if (month.toLowerCase().equals("may")) {
            return 4;
        }

        if (month.toLowerCase().equals("jun")) {
            return 5;
        }

        if (month.toLowerCase().equals("jul")) {
            return 6;
        }

        if (month.toLowerCase().equals("aug")) {
            return 7;
        }

        if (month.toLowerCase().equals("sep")) {
            return 8;
        }

        if (month.toLowerCase().equals("oct")) {
            return 9;
        }

        if (month.toLowerCase().equals("nov")) {
            return 10;
        }

        if (month.toLowerCase().equals("dec")) {
            return 11;
        }

        return -1;
    }

    public static String returnMonth(int month) {
        switch (month) {
        case 0:
            return "Jan";

        case 1:
            return "Feb";

        case 2:
            return "Mar";

        case 3:
            return "Apr";

        case 4:
            return "May";

        case 5:
            return "Jun";

        case 6:
            return "Jul";

        case 7:
            return "Aug";

        case 8:
            return "Sep";

        case 9:
            return "Oct";

        case 10:
            return "Nov";

        case 11:
            return "Dec";
        }

        return "   ";
    }
}

Related

  1. normalizeMonth(final int month)
  2. normalizeMonth(String word)
  3. paraseMonth(String yearMonth)
  4. parseMonth(final int month)
  5. ResolveMonth(String MonthToResolve)
  6. roundMonthUnits(final int defaultUnitValue)
  7. setStatis_month(String year_month)
  8. startDaemonThread(Runnable runnable)
  9. stringToMonth(String m)