We would like to know how to match an arbitrary String to month name.
import java.util.HashSet; import java.util.Collections; import java.text.DateFormatSymbols; /*w w w .ja va 2 s.c o m*/ public class Main { public static void main(String[] args) { HashSet<String> months = new HashSet<String>(24); Collections.addAll(months, DateFormatSymbols.getInstance().getMonths()); Collections.addAll(months, DateFormatSymbols.getInstance().getShortMonths()); System.out.println(months.contains(args[0])); } }