Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0.2
-
Component/s: Converters
-
Labels:None
Description
Under japanese locale, com.thoughtworks.acceptance.BasicTypesTest fails as follows:
[junit] Testcase: testDate(com.thoughtworks.acceptance.BasicTypesTest): FAILED
[junit] expected:<...AM...> but was:<...¸áÁ°...>
[junit] junit.framework.ComparisonFailure: expected:<...AM...> but was:<...¸áÁ°...>
[junit] at com.thoughtworks.acceptance.AbstractAcceptanceTest.assertBothWays(Unknown Source)
[junit] at com.thoughtworks.acceptance.BasicTypesTest.testDate(Unknown Source)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
"¸áÁ°" is a japanese word meaning "AM".
This is because, SimpleDateFormat did not always format 'a' pattern letter to AM/PM.
Explicitly specifying english locale is a solution to this problem?
Index: src/java/com/thoughtworks/xstream/converters/basic/ThreadSafeSimpleDateFormat.java
===================================================================
RCS file: /scm/xstream/xstream/src/java/com/thoughtworks/xstream/converters/basic/ThreadSafeSimpleDateFormat.java,v
retrieving revision 1.5
diff -u -r1.5 ThreadSafeSimpleDateFormat.java
src/java/com/thoughtworks/xstream/converters/basic/ThreadSafeSimpleDateFormat.java 11 May 2004 17:21:42 -0000 1.5
+++ src/java/com/thoughtworks/xstream/converters/basic/ThreadSafeSimpleDateFormat.java 23 Jun 2004 22:38:10 -0000
@@ -4,6 +4,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
/**
- Wrapper around java.text.SimpleDateFormat that can
@@ -84,7 +85,7 @@
}
private DateFormat createNew()
{ - return new SimpleDateFormat(formatString); + return new SimpleDateFormat(formatString, Locale.ENGLISH); }}