JDK-5061061 : SimpleDateFormat: unspecified behavior for reserved pattern letter
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-06-10
  • Updated: 2025-04-08
  • Resolved: 2025-03-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b17Fixed
Related Reports
CSR :  
Relates :  
Description

Name: smR10189			Date: 06/09/2004



The JDK 1.5 spec. doesn't specify behavior if reserved letters are
used as pattern letters.

It only says:
" 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.

The following pattern letters are defined (all other characters from 'A' to 'Z'
and from 'a' to 'z' are reserved)"

The spec. doesn't say that using reserved letters is illegal.
In other words, "reserved" letter doesn't mean "illegal" letter.
So an implementation behavior is undefined because it
can handle reserved letters in the following ways:
  - simply copying them into the output string
  - ignoring them

JDK 1.5.0 implementation rejects patters with reserved letters
with IllegalArgumentException.

======================================================================

Comments
Changeset: 58ef4015 Branch: master Author: Justin Lu <jlu@openjdk.org> Date: 2025-03-27 20:40:05 +0000 URL: https://git.openjdk.org/jdk/commit/58ef4015b7313292a7c7634d3e00e3a904bbdc50
27-03-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24207 Date: 2025-03-24 21:21:20 +0000
24-03-2025

EVALUATION The description should be read that the letters 'A' to 'Z' and 'a' to 'z' are subject to interpretation as pattern letters. Since there are no associated date or time fields with reserved letters, parsing a pattern string with reserved letters should fail. Reserved letters are not "illegal" letters. However, any pattern with pattern letters that can't be interpreted should be considered invalid. The constructors and methods that interpret a given pattern state that they throw an IllegalArgumentException if the given pattern is invalid. Copying reserved letters to output or ignoring them is never a design option. That will break compatibility when reserved letters are used as actual pattern letters in future releases. ###@###.### 2004-06-10 Name: smR10189 Date: 06/10/2004 I'm not agree with evaluation above. An implementation MUST follow the spec. The TCK tests also MUST be based on the spec. You argument that: "any pattern with pattern letters that can't be interpreted should be considered invalid." is only assumption how an implementation should handle such cases. The spec. doesn't say explicitly that using reserved letters in pattern is illegal. Please point me out where is forbidden to use reserved letters. If you think that this is a spec. bug please reassign this bug to the spec. I'm going to reopen this bug. ====================================================================== If you disagree with the spec, how should the constructors and methods do? I haven't heard of any processing systems which treat use of reserved things (e.g., keywords, letters, bit fields, opcodes) to be "valid". If there're such processing systems, give me examples please. ###@###.### 2004-06-10 Need to define what reserved letters mean for serialization. ###@###.### 2004-06-15
10-06-2004