将字符串转成Date
import java.text.SimpleDateFormat; import java.util.Date; public class DateUtil { public static Date ParseRFC3339DateFormat(String p_date) { try{ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); String dts = p_date.replaceAll("([\+\-]\d\d):(\d\d)","$1$2"); return formatter.parse(dts); }catch (Exception e) { return null; } } }
https://stackoverflow.com/questions/2823442/rfc822-timezone-parsing-in-java