I am trying to convert string to Date
, but I am not able to get the format that I want.
My code goes like this:
String inputDate ="1948-06-29";
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd");
Date date = simpleDate.parse(inputDate);
System.out.println("Output : " + date); // Output: Tue Jun 29 00:00:00 CDT 1948
I want the date to print out the same format as the input string like this "1948-06-29"
please let me know if there is any approach to solve this.