Well, you already have the date in String format and that's what the format
method does. I am assuming what you want to do here is to parse
the date (into Date
object) and not format
.
Also, it looks like the date is in French
locale, so you need to use appropriate locale along with SimpleDateFormat
and use parse
method, e.g.:
DateFormat df = new SimpleDateFormat("EEE MMMM dd HH:mm:ss z yyyy", Locale.FRANCE);
Date date = df.parse("dim. janv. 23 24:00:00 +0000 2011");
System.out.println(date);
This would give you the Date
object. If you want to format it differently, you can call format
method with different format.
Update
Also, it looks like you are calling overloaded version of format
method (by passing in a String and not a Date
object. This evantually calls format
method of TextFormat
class (javadoc here) and that's why you get that Exception
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…