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);