• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Report Formatting

 
Mark Mokris
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering how you format a hard copy printout or report in Java. What classes do I look to? Suppose I want to format numbers as dollars and cents, right-justified within 15 print positions, like you can do in other languages.
 
Hari Gangadharan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like you are a COBOL programmer :-). I too was! It is very difficult to format text reports using Java comparing COBOL or older languages that can create reports. You can use the following classes to format the Date and Number: SimpleDateFormat and NumberFormat (Look in java.text package).
However there is no StringFormat class that enables us to right align or left align our strings during report generation. You may have to create your own StringFormat class that can append spaces in front or back - A sample use of the StringFormat may be as follows (Remember you have to create StringFormat):



Hope this helps.
[ February 05, 2003: Message edited by: Hari Gangadharan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic