-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 08/14/2001
java.text.SimpleDateFormat(String, Locale) throws IllegalArgumentException when
pattern contain characters which is can not be interpreted as meta-symbols in
pattern. This behavior contradicts with current JavaDoc which says:
----------- JavaDoc ---------------
Date and time formats are specified by date and time pattern strings. Within
date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to
'z' are interpreted as pattern letters representing the components of a date or
time string. Text can be quoted using single quotes (') to avoid interpretation.
"''" represents a single quote. All other characters are not interpreted;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
they're simply copied into the output string during formatting or matched
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
against the input string during parsing.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
----------------------------------
Such characters should not cause an exception when pattern being verified.
Following minimized test shows the bug:
------------- test.java --------------
import java.text.SimpleDateFormat;
import java.util.Locale;
public class test {
public static void main(String[] args) {
SimpleDateFormat f =
new SimpleDateFormat("yyyy.MM.dd e hh.mm.ss zzz", Locale.ENGLISH);
System.out.println(f.toPattern());
}
}
--------------------------------------
Output:
-------------------------------
% java -version
java version "1.4.0-beta_refresh"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b75)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b75, mixed mode)
% java test
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern
character 'e'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:678)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:497)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:446)
at t1.main(test.java:7)
--------------------------------------------------------
======================================================================
- relates to
-
JDK-4326988 API: SimpleDateFormat throws NullPointerException when parsing with null pattern
-
- Resolved
-