CVSROOT: /sources/classpath Module name: classpath Changes by: Pekka Enberg <penberg> 11/02/16 19:44:29
Modified files: . : ChangeLog java/util : Formatter.java Log message: Fix Formatter.parseInt() wrt. leading zeroes The following test case: public class StringTest { public static void main(String[] args) { System.out.println(String.format("%08x", 1234)); } } produces the following error: Exception in thread "main" java.lang.NumberFormatException: invalid character at position 2 in 08 at java.lang.Integer.parseInt(Integer.java:837) at java.lang.Integer.decode(Integer.java:568) at java.util.Formatter.parseInt(Formatter.java:1191) at java.util.Formatter.parseArgumentIndex(Formatter.java:1212) at java.util.Formatter.format(Formatter.java:1326) at java.util.Formatter.format(Formatter.java:1442) at java.lang.String.format(String.java:1984) at java.lang.String.format(String.java:1990) at StringTest.main(StringTest.java:3) This patch fixes the issue by switching to Integer.parseInt() in java.util.Formatter.parseInt(). Reviewed-by: Dr Andrew John Hughes <gnu_and...@member.fsf.org> 2010-02-16 Pekka Enberg <penb...@kernel.org> * java/util/Formatter.java: (parseInt): Use Integer.parseInt() insted of Integer.decode() because the latter doesn't work with leading zeros which are used in String.format() formatting, for example. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.9815&r2=1.9816 http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Formatter.java?cvsroot=classpath&r1=1.7&r2=1.8