[英]SimpleDateFormat different behaviour depending on java version
In the netty framework there is the following code: 在netty框架中,有以下代码:
final class CookieDateFormat extends SimpleDateFormat {
private static final long serialVersionUID = 1789486337887402640L;
CookieDateFormat() {
super("E, d-MMM-y HH:mm:ss z", Locale.ENGLISH);
setTimeZone(TimeZone.getTimeZone("GMT"));
}
}
The issue I am having is that the above's output varies depending on the version of the jvm when I run it. 我遇到的问题是,上面的输出根据我运行jvm的版本而有所不同。
Is there any way to change the behavior on java 1.6 to match the output of 1.7 without having to alter the code (since I would prefer not having to change code in netty). 有什么方法可以更改java 1.6上的行为以匹配1.7的输出而不必更改代码(因为我宁愿不必更改netty中的代码)。
Try to use d-MMM-yyyy
instead of d-MMM-y
. 尝试使用d-MMM-yyyy
而不是d-MMM-y
。 I hope that difference in seconds (41 vs 14) is your typing mistake. 我希望您输入错误的时间以秒为单位(41 vs 14)。 Otherwise I cannot explain this difference. 否则,我无法解释这种差异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.