import java.util.Scanner;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;
import java.text.DateFormat;
import java.util.Locale;
class Main {
public static void main(String[] args)throws ParseException{
Scanner sc=new Scanner(System.in);
System.out.println("enter the date");
String p=sc.nextLine();
SimpleDateFormat d=new SimpleDateFormat("dd/MM/yyyy",Locale.ENGLISH);
SimpleDateFormat i=new SimpleDateFormat("dd/MM/yyyy");
try {
Date m=d.parse(p);
System.out.println("The input date is"+i.format(m));
} catch(ParseException e){
e.printStackTrace();
}
}
}
when I am running this problem I am getting error as
java.text.ParseException:Unparseable date: "27-01-1978" at java.text.DateFormat.parse(DateFormat.java:366) at Main.main(Main.java:19).
What should be done in order to avoid that error.