1、GMT日期转换,eg:"Fri, 01 Mar 2013 04:00:09 GMT"
- //转换为java 默认Date
- String aa = "Fri, 01 Mar 2013 04:00:09 GMT";
- try {
- Date ymd = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",Locale.ENGLISH).parse(aa);
- System.out.println("ymd:"+ymd);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //转换并格式化为指定字符串形式
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String formatDate;
- try {
- formatDate = formatter.format(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",Locale.ENGLISH).parse(aa));
- System.out.println("formatDate:"+formatDate);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- 输出结果:ymd:Fri Mar 01 12:00:09 CST 2013 formatDate:2013-03-01 12:00:09
转载于:https://blog.51cto.com/liuya2012/1195770