Question : date parse java
Answered by : talented-tiger-6906ruwo7pne
//Jdk 7 and above
//DO NOT USE DATE.PARSE(), IS DEPRECATED AND VERY OLD
import java.text.SimpleDateFormat;
import java.util.Date;
//Parse the date
//throws ParseException
String input = "Thu Jun 18 20:56:02 EDT 2009";
SimpleDateFormat parser = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Date date = parser.parse(input);
//Format the parsed date
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = formatter.format(date);
Source : https://stackoverflow.com/questions/999172/how-to-parse-a-date | Last Update : Wed, 10 Aug 22