String str = "Sun Dec 04 00:30:55 CST 2005";
SimpleDateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
System.out.println(df.parse(str));
str = "Sun, 04 Dec 2005 00:30:55";
df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.ENGLISH);
System.out.println(df.parse(str));
str = "Mon, 18 Apr 2005 10:25:40 +0200";
df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
System.out.println(df.parse(str));
str = "2005-12-04";
df = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(df.parse(str));
str = "2005-12-4 0:30:55";
df = new SimpleDateFormat("yyyy-MM-dd H:mm:ss");
System.out.println(df.parse(str));
注意使用: apache common DateUtil类
阅读(1293) | 评论(0) | 转发(0) |