import java.text.SimpleDateFormat;
import java.util.Date;
public class StringToDateExample1 {
public static void main(String[] args)throws Exception {
String sDate1="31/12/1998";
Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(sDate1);
System.out.println(sDate1+" "+date1);
}
import java.text.SimpleDateFormat;
import java.util.*;
class class_name
{
public static void main(String[] args) throws Exception // You can also use try-catch blocks.
{
System.out.println("dd-mm-yyyy");
Scanner scanner = new Scanner(System.in);
String date = scanner.nextLine();
Date date1=new SimpleDateFormat("dd-MM-yyyy").parse(date);
System.out.println(date1);
}
}