import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class JavaApplication {
public static void main(String[] args) {
String sDate = "2024-04-28";
try {
SimpleDateFormat sdfFrom = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdfFrom.parse(sDate);
System.out.println(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.format(date));
} catch (ParseException e) {
System.out.println(e.getMessage());
}
}
}
/*
run:
Sun Apr 28 00:00:00 GMT 2024
2024-04-28
*/