Similar to the Thu May 2017 00:00:00 gmt+0800 (China Standard Time) format, the time is converted to 2017/05/18 or seconds, as follows:
/**
*@paramDatdstring Thu May 2017 00:00:00 gmt+0800 (China Standard Time) *@returnmonth and year day; */public static string Parsetime (String datdstring) {datdstring = Datdstring.replace ("GMT", ""). ReplaceAll ("\ (. *\\)
", ""); Converts a string to a date type, formatted 2016-10-12 simpledateformat format = new SimpleDateFormat ("EEE MMM dd yyyy HH:mm:ss z", Locale.engli
SH);
Date Datetrans = null;
try {Datetrans = Format.parse (datdstring);
return new SimpleDateFormat ("Yyyy-mm-dd"). Format (Datetrans). Replace ("-", "/");
catch (ParseException e) {e.printstacktrace ();
return datdstring; }
/**
*@paramDatdstring "Tue June 12:10:11 gmt+08:00 2016"; *@returnTime sec/public static string Parsehour (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 new SimpleDateFormat ("HH:mm:ss"). Format (Datetrans);
catch (ParseException e) {e.printstacktrace ();
return datdstring; }