文章引用于此点击打开链接
Java把“Wed Oct 24 23:39:10 +0800 2012”这样的格式,转换成想要的格式,转到自己的博客,作为自己的日后查找学习方便,同时跟其他朋友分享
public class DateTest {
public static final String SOURCE = "Wed Apr 11 16:18:42 +0800 2012";
public static void main(String[] args) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss Z yyyy", new Locale("ENGLISH", "CHINA"));
Date myDate = sdf.parse(SOURCE);
System.out.println(myDate);
sdf.applyPattern("EEE MMM dd HH:mm:ss Z yyyy");
System.out.println(sdf.format(myDate));
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
new Locale("CHINESE", "CHINA"));
System.out.println(sdf2.format(myDate));
sdf2.applyPattern("yyyy年MM月dd日 HH时mm分ss秒");
System.out.println(sdf2.format(myDate));
long miliSeconds = myDate.getTime();
System.out.println("自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象经过的毫秒数为:"
+ miliSeconds + "毫秒");
/*
* Wed Apr 11 16:18:42 CST 2012 Wed Apr 11 16:18:42 +0800 2012
* 2012-04-11 16:18:42 2012年04月11日 16时18分42秒 自 1970 年 1 月 1 日 00:00:00
* GMT 以来此 Date 对象经过的毫秒数为:1334132322000毫秒
*/
}
}