This code converts a 3-letter English month abbreviation to its numeric equivalent (as a string).
public static String numericMonth(String monthInFull) {
monthInFull = monthInFull.toUpperCase();
if (monthInFull.equals("JAN")) { return "01"; }
if (monthInFull.equals("FEB")) { return "02"; }
if (monthInFull.equals("MAR")) { return "03"; }
if (monthInFull.equals("APR")) { return "04"; }
if (monthInFull.equals("MAY")) { return "05"; }
if (monthInFull.equals("JUN")) { return "06"; }
if (monthInFull.equals("JUL")) { return "07"; }
if (monthInFull.equals("AUG")) { return "08"; }
if (monthInFull.equals("SEP")) { return "09"; }
if (monthInFull.equals("OCT")) { return "10"; }
if (monthInFull.equals("NOV")) { return "11"; }
if (monthInFull.equals("DEC")) { return "12"; }
return "";
}
Is it possible to create an array (or Enum?) listing the month names and their respective index (or index + 1) and avoid this excess of if?