This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "format" Watch "format" New topic
Author

format

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

System.out.printf("%-011.3f%n",232554.45646);


Exception in thread "main" java.util.IllegalFormatFlagsException: Flags = '-0'
at java.util.Formatter$FormatSpecifier.checkNumeric(Formatter.java:2979)
at java.util.Formatter$FormatSpecifier.checkFloat(Formatter.java:2953)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2686)
at java.util.Formatter.parse(Formatter.java:2528)
at java.util.Formatter.format(Formatter.java:2469)
at java.io.PrintStream.format(PrintStream.java:970)
at java.io.PrintStream.printf(PrintStream.java:871)
at Print.main(Print.java:25)

I'm expecting: 0232554.456

My one regret in life is that I am not someone else.
- Woody Allen
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

aha! got it.I was using - and 0 together.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: format
 
It's not a secret anymore!