string datdString='Wed Oct 12 2016 00:00:00 GMT+0800 (中国标准时间)'将字符串转化为date类型,格式2016-10-12


public static void main(String[] args) throws Exception {
<span style="white-space:pre">	</span>String datdString="Wed Oct 12 2016 00:00:00 GMT+0800 (中国标准时间)";
	datdString = datdString.replace("GMT", "").replaceAll("\\(.*\\)", "");
	//将字符串转化为date类型,格式2016-10-12
	SimpleDateFormat format =  new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss z",Locale.ENGLISH);
	Date dateTrans = format.parse(datdString);
	System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(dateTrans));
		
		
	}

没有更多推荐了,返回首页