import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TesterA
{
public static void main(String[] args)
{
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
String dateInString = "7-Jun-2013";
try
{
Date date = formatter.parse(dateInString);
System.out.println(date);
System.out.println(formatter.format(date));
}
catch (ParseException e)
{
e.printStackTrace();
}
}
}
I was trying to run this sample code copy from a web, but it doesn't work. How should I change it?
This is the error I got
java.text.ParseException: Unparseable date: "7-Jun-2013"
at java.text.DateFormat.parse(DateFormat.java:366)
at TesterA.main(TesterA.java:14)