I have a value like the following Mon Jun 18 00:00:00 IST 2012
and I want to convert this to 18/06/2012
How to convert this?
I tried this method
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);
}
but it throws following exception :
java.text.ParseException: Unparseable date: "Mon Jun 18 00:00:00 IST 2012"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…