Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

toddburch

macrumors 6502a
Original poster
Dec 4, 2006
748
0
Katy, Texas
Left, right, center justification. Seems like a basic feature, but I can't seem to find it. Must be buried in some obscure package. Any ideas?

Also, number formatting. Let's say I want to format numbers 1 through 100 with leading blanks or zeros in a report to keep everything lined up nice and tidy. How to?

Thanks, Todd
 

tilman

macrumors regular
Feb 28, 2006
126
0
Left, right, center justification. Seems like a basic feature, but I can't seem to find it. Must be buried in some obscure package. Any ideas?

Also, number formatting. Let's say I want to format numbers 1 through 100 with leading blanks or zeros in a report to keep everything lined up nice and tidy. How to?

Thanks, Todd

If you are using Java 1.5 or newer, you can use the newly introduced formatters:
String.format("%1$-20s %2$-20s %3$6d %4$9.2f", name, operation, getCalls(), getTime());
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.