How do I use the java.util.Formatter class to format output?

John Zukowski

There are at least three ways to generate formatted output:

  • Use the format() method of an instance of Formatter.
  • Use the format()/printf method of an OutputStream, as in System.out.format("The time is %tT.", Calendar.getInstance());
  • Use the format() method of String, as in String.format("Today is %1$tm %1$te,%1$tY", Calendar.getInstance());
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact