On the problem of time type conversion for novices :
Get the time for the string , The format is :“2021-01-20T10:09:11Z”.
Easy to understand solutions :
First, convert the string to Date type :
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z’”);
Date applyDate = sdf.parse(“2021-01-20T10:09:11Z”);
And then Date Type to the desired string type :
SimpleDateFormat sdf1 = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
String stringDate= sdf1.format(applyDate);
The picture is the actual application scene :
Sometimes the string type is :“2021-01-20T10:09:11”, Then remove the following ones accordingly ’Z’ That's it .
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss”);
Date applyDate = sdf.parse(“2021-01-20T10:09:11”);
Technology