MessageBundle ???

Mark Wielaard mark@klomp.org
Fri Apr 1 19:32:00 GMT 2011


On Fri, 2011-04-01 at 18:43 +0100, Andrew Haley wrote:
> >> java.lang.NumberFormatException: invalid character at position 2 in 09
> > 
> > That's just a bug: leading zeroes in format fields aren't being handled
> > correctly.  The "09" is being parsed as an octal number because it begins
> > with a zero.
> 
> The fix for the exception is
> 
> Index: Formatter.java
> ===================================================================
> --- Formatter.java	(revision 171834)
> +++ Formatter.java	(working copy)
> @@ -1188,7 +1188,7 @@
>        advance();
>      if (start == index)
>        return -1;
> -    return Integer.decode(format.substring(start, index));
> +    return Integer.parseInt(format.substring(start, index));
>    }
> 

Coincidentally the exact same problem and fix were discovered by Pekka
and went into GNU Classpath recently.

2010-02-16  Pekka Enberg  <penberg@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.





More information about the Java mailing list