时间转换
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class D {
public static void main(String[] args) {
// System.out.println(parseTime("Thu May 18 2017 10:00:00 GMT+0800"));
System.out.println(parseTime("Wed May 22 2019 04:16:41 GMT+0800"));
// Wed, 22 May 2019 04:16:41
}
/**
* 时间转换
* @param datdString
* @return
*/
public static String parseTime(String datdString) {
datdString = datdString.replace("GMT", "").replaceAll("\\(.*\\)", "");
//将字符串转化为时间戳
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss z", Locale.ENGLISH);
Date dateTrans = null;
try {
dateTrans = format.parse(datdString);
return dateTrans.getTime()+"";
} catch (ParseException e) {
e.printStackTrace();
}
return datdString;
}
}