[ajug-members] The method format(String, Object[]) in the type Formatter is not applicable for the arguments (String, String, int)
Christopher Fowler
cfowler at outpostsentinel.com
Thu Aug 9 19:02:32 EDT 2007
I was doing this in 1.4:
String.format("%s%06d", prefix, i);
That had failed so I did a search on google and saw an example using the
Formatter class.
Here is what I'm trying:
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb, Locale.US);
formatter.format("%s%06d", perfix, i);
This works here:
StringBuilder sb = new StringBuilder();
Object a[] = { prefix, new Integer(i) };
Formatter formatter = new Formatter(sb, Locale.US);
formatter.format("%s%06d", a);
//String n = String.format("%s%06d", prefix, i);
String n = sb.toString();
Seems to me like a lot of work vs the old method.
On Thu, 2007-08-09 at 17:47 -0400, Björn Gustafsson wrote:
> Which Formatter class are you using? As I recall, java.util.Formatter
> was new in Java 1.5. I wouldn't think they'd intentionally change its
> behavior in 1.6, so maybe the "..." syntax is broken? I can see how
> it might also be a boxing/unboxing failure, i.e. if you repackaged the
> int as an Integer it might succeed. (Though that'd still be a bug.)
>
> On 8/9/07, Christopher Fowler <cfowler at outpostsentinel.com> wrote:
> > I'm compiling a program in Java 1.6 that I've always have been able to
> > compile in 1.4. I'm not getting this error that I'm not sure how to
> > fix:
> >
> > formatter.format("%s%06d", prefix, i);
> > ^^^^^^
> > The method format(String, Object[]) in the type Formatter is not
> > applicable for the arguments (String, String, int)
> >
> > It seems to me that they've may have changed the conventions used by
> > printf to their own?
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
More information about the ajug-members
mailing list