Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4989961
Votes 0
Synopsis (fmt) Formatter am/pm and AM/PM date/time suffixes are backwards
Category java:classes_util
Reported Against tiger-beta
Release Fixed 1.5(tiger-b49)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 5032972 , 5061412
Submit Date 06-FEB-2004
Description




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 :
 customer  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) 
======================================================================
Work Around
N/A
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.

--   xxxxx@xxxxx   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.

--   xxxxx@xxxxx   2004-04-15
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang