I have a string of time format
2015-08-14T06:00:00+08:00
and I want to convert that to timeStamp but with:
public static Long convertTimeStringToTimeStampMilSec(String timeStr){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ddTHH:MM:SS+08:00");
try {
Date d = dateFormat.parse(timeStr);
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.getTimeInMillis();
}catch (Exception e){
e.printStackTrace();
return null;
}
}
And get exception:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'T'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:585)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:560)
How to deal with this?