Re: MessageBundle ???

Mark Wielaard <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <[email protected]>
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  <[email protected]>

        * 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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.