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.
posted 13 years ago
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 ]
<B>Hari Gangadharan</B><BR>Unix is user friendly..<BR>but it chooses to whom it is friendly with!