转换注意格式;
String strDate = "2020-09-25T09:51:40.527Z";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'.'sss'Z'");
Date datetime = null;
try {
datetime = sdf.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(datetime);
long time = datetime.getTime();
System.out.println(time);
对比一下
String strDate = "2020-09-18T07:14:33+0000";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'+'sss");
Date datetime = null;
try {
datetime = sdf.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}
long time = datetime.getTime();
System.out.println(time);