dateformat后时间少了8小时问题
经调查刚刚程序里用的format为:
org.apache.tools.ant.util.DateUtils.format
源代码如下:
public static String format(Date date, String pattern)
{
DateFormat df = createDateFormat(pattern);
return df.format(date);
}
private static DateFormat createDateFormat(String pattern)
{
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
TimeZone gmt = TimeZone.getTimeZone("GMT");//关键所在
sdf.setTimeZone(gmt);
sdf.setLenient(true);
return sdf;
}