public class DateUtil{
public static void main(String[] args) throws ParseException {
String str = "Mon, 08 Dec 2014 09:01:47 GMT";
String str1 = "Mon Dec 31 00:00:00 CST 2014";
System.out.printf("%tF %<tT%n", date);
Date date1 = parse(str, "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
System.out.println("=========================================");
System.out.printf("%tF %<tT%n", date1);
}
public static Date parse(String str, String pattern, Locale locale) {
if(str == null || pattern == null) {
return null;
}
try {
return new SimpleDateFormat(pattern, locale).parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static String format(Date date, String pattern, Locale locale) {
if(date == null || pattern == null) {
return null;
}
return new SimpleDateFormat(pattern, locale).format(date);
}
}