<> one , Error message

java.text.ParseException: Unparseable date:
"2018-11-07T11:40:13.202518781+08:00"

<> two , background

Docking with third-party platform data , The time format transmitted is 2018-11-07T11:40:13.202518781+08:00, You need to convert it to 2018-11-07
11:40:13 Time format for .
Many methods have been searched on the Internet , It feels like a pit , Record it here , Beware of entering the pit next time .

<> three , resolvent
String data = "2018-11-07T11:40:13.202518781+08:00"; try { SimpleDateFormat
sdf1=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss."); SimpleDateFormat sdf2=new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = sdf1.parse(data); String
time= sdf2.format(date); System.out.println(" time :" + time); }catch (Exception e)
{ e.printStackTrace(); }
Operation results :
time :2018-11-07 11:40:13
Pit encountered : Use time format yyyy-MM-dd'T'HH:mm:ss.SSS+08:00 Convert , Then it was found that the time was inconsistent .
Then read it stackoverflow Website discovery Need to delete nanoseconds , use new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.");

Technology