Java Month Format formatMonthlyPeriod(String month)

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

Description

format Monthly Period

License

Open Source License

Declaration

public static String formatMonthlyPeriod(String month) 

Method Source Code

//package com.java2s;

public class Main {
    public static String formatMonthlyPeriod(String month) {
        String[] monthNames = { "January", "February", "March", "April",
                "May", "June", "July", "August", "September", "October",
                "November", "December" };

        StringBuffer formattedPeriod = new StringBuffer();

        String m = month.substring(0, month.indexOf(" "));
        String y = month.substring(month.indexOf(" ") + 1, month.length());

        int mnth = -1;
        for (int i = 0; i < monthNames.length; i++) {
            if (monthNames[i].equals(m)) {
                mnth = i;/*from w  ww  .j a  v  a2  s  .  c o  m*/
                break;
            }
        }

        formattedPeriod.append(mnth);
        formattedPeriod.append("-");
        formattedPeriod.append(y);

        return formattedPeriod.toString();
    }
}

Related

  1. formatMonth(final int year, final int month)
  2. formatMonth(int month)
  3. formatMonth(int month, Locale locale, boolean longFormat)
  4. formatMonth(String dateOrign)
  5. formatMonthDay(int decimal)
  6. getAfterByNMonth(String format, int months)
  7. getCurrMonthFirstDaySlashFormat()
  8. getDisplayMonth(Date time, int monthBefore, int monthAfter, SimpleDateFormat format)
  9. getFirstDayOfNextMonth(String dateFormat)