1.Thu Feb 01 2018 00:00:00 GMT 0800 (中国标准时间) 转 Date
startTime = "Thu Feb 01 2018 00:00:00 GMT 0800 (中国标准时间)";
String SPLIT_STRING = "(中国标准时间)";
startTime = startTime.split(Pattern.quote(SPLIT_STRING))[0].replace(REPLACE_STRING[0], REPLACE_STRING[1]);
SimpleDateFormat sf1 = new SimpleDateFormat("E MMM dd yyyy HH:mm:ss z", Locale.US);
Date date = sf1.parse(startTime);
2.Date转String
GST格式字符串转换成yyyy-MM-dd HH:mm:ss格式的时间
String dateStr = "Mon Oct 26 22:22:22 CST 2022";
DateFormat cst = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat gmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
Date dateTime = gmt.parse(dateStr);
String dateString = cst.format(dateTime);
System.out.println(dateString);
String sdate;
Date ddate;
sdate=(new SimpleDateFormat("yyyy-MM-dd")).format(ddate);
3.String转Date
String time = "2012-12-06";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(time);
标签:00,Java,String,dd,SimpleDateFormat,yyyy,Date From: https://www.cnblogs.com/pika-pikaqiu/p/17410956.html