Reputation: 12395
I have used this code to parse a String received from Json in Date Format.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try{
Date myDateConference = sdf.parse(jsonO.getString("myDateConference"));
}
catch(ParseException e){
e.printStackTrace();
}
The String of the date is something in this form 2012-08-02T00:00:00
But I get this exception
java.text.ParseException: Unparseable date: "2012-08-02T00:00:00"
What is wrong?
Upvotes: 0
Views: 1586
Reputation: 467
There is a T in your source String:
"2012-08-02<b>T</b>00:00:00"
Upvotes: 1
Reputation: 132992
use
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
instead of
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Upvotes: 4