Here you can find the source of formatMonthlyPeriod(String month)
public static String formatMonthlyPeriod(String month)
//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(); } }