Java 8 RFR: 6178739 - Formatter (original) (raw)

Java 8 RFR: 6178739 - Formatter - Zero padding flag with zero width

Brian Burkhalter brian.burkhalter at oracle.com
Fri Jun 28 19:10:59 UTC 2013


Continuing this thread

http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/018326.html

with respect to this issue

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178739

this Request for Review proposes the following change to the Formatter javadoc specification:

diff -r 8d577b3a6ca4 src/share/classes/java/util/Formatter.java --- a/src/share/classes/java/util/Formatter.java Fri Jun 28 11:09:10 2013 -0700 +++ b/src/share/classes/java/util/Formatter.java Fri Jun 28 11:58:45 2013 -0700 @@ -190,7 +190,7 @@

The change is to require the field width to be positive rather than non-negative. Allowing a zero minimum field width seems meaningless. This matches the current behavior as defined by the format specifier regular expression:

private static final String formatSpecifier
    = "%(\\d+\\$)?([-#+ 0,(\\<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])";

A CCC request for the above would naturally need to be approved if this is change were deemed acceptable.

An alternative, as previously stated, would be to handle cases like %0.4f specially but this seems to violate the letter of the specification as currently written. It would however match the behavior of C and not require a CCC request, FWIW.

Thanks,

Brian



More information about the core-libs-dev mailing list