Date Parse Java

[Solved] Date Parse Java | Scala - Code Explorer | yomemimo.com
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

Answers related to date parse java

Code Explorer Popular Question For Scala