1、使用HttpClient内部时间帮助类格式化导致
原因:格式化过程中时区设置与Date时间中的时区不一致导致问题
org.apache.commons.httpclient.util.DateUtil类中的方法
public static String formatDate(Date date, String pattern) {
if (date == null) {
throw new IllegalArgumentException("date is null");
} else if (pattern == null) {
throw new IllegalArgumentException("pattern is null");
} else {
SimpleDateFormat formatter = new SimpleDateFormat(pattern, Locale.US);
formatter.setTimeZone(GMT);
return formatter.format(date);
}
}
改为:
public static String format(Date date, String format) {
if (null != date && !StrUtil.isBlank(format)) {
SimpleDateFormat sdf = new SimpleDateFormat(format);
if (date instanceof DateTime) {
TimeZone timeZone = ((DateTime)date).getTimeZone();
if (null != timeZone) {
sdf.setTimeZone(timeZone);
}
}
return format(date, (DateFormat)sdf);
} else {
return null;
}
}