解决方法:(String类型无法直接parse为一个date类型,所以需要先把String字符串,格式化为一个date类型,最后再格式化为你想要的格式)
public String formatDate(String inputDate){
try{
DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.US);
Date date = inputFormat.parse(inputDate);
return outputFormat.format(date);
}catch (Exception e){
e.printStackTrace();
return null;
}
}