I'm currently working on a project that requires me to transform a date from one format to another.
Here is my code
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class testDate {
static String date = "Wed Mar 27 18:14:25 CET 2019"; // String representing received date
static final String originalFormatS = "EEE MMM dd HH:mm:ss zzz yyyy"; // Corresponding date format
static final String displayFormatS = "dd/MM/yy"; // Wanted output format
public static void main (String[] args) throws Exception {
DateFormat originalFormat = new SimpleDateFormat(originalFormatS);
DateFormat displayFormat = new SimpleDateFormat(displayFormatS);
Date parsedDate = originalFormat.parse(date);
String outputDate = displayFormat.format(parsedDate);
System.out.println(outputDate);
}
}
But then I get java.text.ParseException: Unparseable date: "Wed Mar 27 18:14:25 CET 2019"
I tried new Date(date);
but it says it's deprecated...
Any idea about that ? Thanks in advance