File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
EJB 3 in Action
this week in the
EJB and other Java EE Technologies
Programmer Certification (SCJP/OCPJP)
Java's formatting capabilities
Joined: Oct 02, 2005
Dec 31, 2011 09:46:45
Is there any easier way of understanding how the numerous ways of formatting in
are related? I get confused of the following:
System.out.printf() System.out.format() String.format() System.console.format() new Formatter(new StringBuffer("Test").format(); DecimalFormat.format(value); NumberFormat.format(value);
Are the above classes/methods related in anyway? What is the best way to understand the differences and which to use in which situation?
As an example, System.out.printf, System.out.format and String.format all use the same syntax and format flags. I cant see what the difference is in all three of them.
Don't get me started about those stupid
subject: Java's formatting capabilities
Padding a string to 5 digits
Formatting a string that contains percent symbol.
Formatting with printf() and format
Just finished my first java program :-) Can you please give me suggestions on making my code better?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014