diff options
author | slixurd <slixurd@users.noreply.github.com> | 2019-09-22 19:57:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-22 19:57:07 +0800 |
commit | dd18488db80f556084ca8a303c9c5716ce0cf230 (patch) | |
tree | 53878878116a9894721ead507e446dc952763577 /container-accesslogging | |
parent | 5944399213e87c5416b50297fd5dd87a63554992 (diff) |
fix test case fail in LogFormatterTestCase
better define locale to us avoiding some special locale such as china/france which called sep to 9月/sept
the test case will fail in enviroment using zh_CN.UTF-8
org.junit.ComparisonFailure: expected:<test20030825133035[Aug]> but was:<test20030825133035[8月]>
Diffstat (limited to 'container-accesslogging')
-rw-r--r-- | container-accesslogging/src/main/java/com/yahoo/container/logging/LogFormatter.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFormatter.java b/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFormatter.java index adb4583d405..87d846ad18c 100644 --- a/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFormatter.java +++ b/container-accesslogging/src/main/java/com/yahoo/container/logging/LogFormatter.java @@ -22,13 +22,13 @@ public class LogFormatter extends Formatter { static SimpleDateFormat yyyyMMdd; static { - ddMMMyyyy = new SimpleDateFormat("[dd/MMM/yyyy:HH:mm:ss Z]"); + ddMMMyyyy = new SimpleDateFormat("[dd/MMM/yyyy:HH:mm:ss Z]", Locale.US); ddMMMyyyy.setTimeZone(TimeZone.getTimeZone("UTC")); - dfMMM = new SimpleDateFormat("MMM"); + dfMMM = new SimpleDateFormat("MMM", Locale.US); dfMMM.setTimeZone(TimeZone.getTimeZone("UTC")); - yyyyMMdd = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); + yyyyMMdd = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]", Locale.US); yyyyMMdd.setTimeZone(TimeZone.getTimeZone("UTC")); } @@ -102,7 +102,7 @@ public class LogFormatter extends Formatter { * </ul> */ public static String insertDate(String pattern, long time) { - DateFormat df = new SimpleDateFormat("yyyy.MM.dd:HH:mm:ss.SSS Z"); + DateFormat df = new SimpleDateFormat("yyyy.MM.dd:HH:mm:ss.SSS Z", Locale.US); df.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = new Date(time); String datetime = df.format(date); |