如何将 “星期一 Jun 18 00:00:00 IST 2012” 转换为 18/06/2012?java.time格式选择不当关于 java.time
我有一个如下所示的值,我想将其转换为Mon Jun 18 00:00:00 IST 2012
18/06/2012
如何转换这个?
我试过这种方法
public String toDate(Date date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date theDate = null;
//String in = date + "/" + month + "/" + year;
try {
theDate = dateFormat.parse(date.toString());
System.out.println("Date parsed = " + dateFormat.format(theDate));
} catch (ParseException e) {
e.printStackTrace();
}
return dateFormat.format(theDate);
}
但它会引发以下异常:
java.text.ParseException: Unparseable date: "Mon Jun 18 00:00:00 IST 2012"