package ImoocWeb;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* 日期转换
* 10/Nov/2016:00:01:02 +0800 ==> 2016-11-10 00:01:02
*
*/
public class ParseDateUtils {
public static String parseDate(String dateStr){
SimpleDateFormat input_date = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z", Locale.ENGLISH);
SimpleDateFormat output_date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String finalDate = "";
try {
Date parse_date = input_date.parse(dateStr);
finalDate = output_date.format(parse_date);
} catch (ParseException e) {
e.printStackTrace();
}
return finalDate;
}
public static void main(String[] args){
// 10/Nov/2016:00:01:02 +8000 ==> yyyy-MM-dd HH:mm:ss
System.out.println(ParseDateUtils.parseDate("10/Nov/2016:00:01:02 +0800"));
}
}