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?
use
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
instead of
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
您的源字符串中有一个T:
"2012-08-02<b>T</b>00:00:00"
将格式更改为
yyyy-MM-dd'T'HH:mm:ss
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.