import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class a {
public static void main(String[] args) throws Exception {
test();
}
public static void test() throws ParseException{
String oldDateStr = "2019-11-27T07:50:20.837Z";
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
Date date = df.parse(oldDateStr);
SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
Date date1 = df1.parse(date.toString());
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df2.setTimeZone(TimeZone.getTimeZone("GMT"));
String format = df2.format(date1);
System.out.println(format);
}
}
运行结果如下: