/* package whatever; // don't place package name! */
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
// arguments are passed using the text field below this editor
public static void main
(String[] args
) {
String[]strs
= {"1st-May-2013",
"10th-Jun-2002",
"2nd-Apr-1996"};
LocalDate d = ordinalStringToDate(str);
}
}
private static LocalDate ordinalStringToDate
(String str
){ return LocalDate.parse(str.replaceAll("(st|nd|rd|th)", ""), DateTimeFormatter.ofPattern("d-MMM-yyyy"));
}
}