JDK-4989961 : (fmt) Formatter am/pm and AM/PM date/time suffixes are backwards
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-02-06
  • Updated: 2017-05-16
  • Resolved: 2004-04-26
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.
Other
5.0 b49Fixed
Related Reports
Relates :  
Description

Name: rmT116609			Date: 02/05/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
The docs for java.util.Formatter (http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html) say:

'p'  	 Locale-specific morning or afternoon marker in upper case, e.g."AM" or "PM".
'P' 	Locale-specific morning or afternoon marker in lower case, e.g."am" or "pm".

Surely this is backwards? Shouldn't an uppercase "P" indicate uppercase AM/PM and vice versa?

I have not tested if this is a documentation bug or is actually implemented like this, but I would strongly suggest this is not the behaviour developers would expect.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Look at http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html
2) Search for  "Locale-specific morning or afternoon marker in upper case"
3) Read "p" mean "AM/PM" and "P" means "am/pm"

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
At step 3 (above) I would expect to read:
"P" mean "AM/PM" and "p" means "am/pm"

Then step (4) would be:

4) Rejoice in this wonderful, intutative new feature


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Unexpected Format Error

my.head.CannotComprehendError at line: 'p'  	 Locale-specific morning or afternoon marker in upper case, e.g."AM" or "PM".

REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 237452) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b49 tiger-beta2
14-06-2004

EVALUATION Sigh. Yes, this may not be the intuitive behaviour depending on the developer's experience. No, this was not an error in the documentation or the implemenation. The Formatter documentation says that the date/time formats are a subset of (and inspired by) those defined by GNU date and POSIX strftime. Both of these references use 'P' for "am/pm" and 'p' for "AM/PM". Here's the reference for the GNU date descriptions: http://www.gnu.org/software/coreutils/manual/html_node/coreutils_134.html#SEC134 Similar documenation exists for POSIX strftime. That said, these conversions are only _inspired_ by those references, while it would be counter-intuitive for those users who are familiar with them, we can choose to switch the definitions. I'll leave this bug open to determine whether there is sufficient demand to make such a change before we ship the final version of jdk1.5. -- iag@sfbay 2004-02-06 I've gotten more requests to make this change. This change seems reasonable for the following reasons: - The difference between the references and the Java implementation would be minor. - Date/time suffixes are inspired by those external specifications. The suffixes are not required to follow those specs. The Formatter spec should emphasize the "looseness" of this dependency. - Format specifiers for date/time suffixes don't exist in non-Java implementations of printf. -- iag@sfbay 2004-04-15
15-04-2004