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

toddburch

macrumors 6502a
Original poster
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
 
Thanks DrQ. I will look into these.

I guess I'm spoiled with Ruby string handling capabilities, and REXX too.

Todd
 
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());
 
String.format works perfectly. Not sure how I missed that - it's right there in the doc! Duh!

Thanks, Todd
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.