I am trying to input the date from the user. But the code is giving error at the parse method. The code I am trying is below.
import java.util.*;
import java.text.SimpleDateFormat;
public class date_parse {
public static void main(String args[]) {
Scanner input=new Scanner(System.in);
String s=input.nextLine();
SimpleDateFormat f= new SimpleDateFormat("dd-MM-yyyy");
System.out.println(f.parse(s));
}
}
NOTE -: The code is running well if I directly provide string format date like "01-01-2000" in place os s in parse method