RFC822格式转换为date并算出毫秒数

来源:互联网 发布:全国中小学数据库 编辑:程序博客网 时间:2024/06/05 06:57

public static long isoStrParseToDate(String isoDateStr) {

long result = 0L;
try {
String pattern = "yyyy-MM-dd'T'HH:mm:ssZ";
SimpleDateFormat sdf = new SimpleDateFormat(pattern,Locale.CHINA);
isoDateStr = sdf.format(new Date(isoDateStr));//将传入的字符串转ISO 8601格式
result = sdf.parse(isoDateStr).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
return result;

}


public static void main(String[] args) {
System.out.println(isoStrParseToDate("Wed, 02 Oct 2002 15:00:00 +0200 "));//传入RFC822类型
 }