• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NumberFormat Question

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below prints $100.00, I want it to print $100.00 USD. I thought from the documentation that getCurrencyInstance got me an object that could do that. The object contains the right currency...what am I doing wrong?


[ January 11, 2006: Message edited by: Luke Shannon ]
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This works, but still confused why the format method doesn't write out the currency on its own....

Luke
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because a NumberFormat is for formatting numbers. It may be that the number in question is a currency amount, or it may not. So if you want the currency description as part of the output, you have to say so.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello;

I thought by calling getCurrencyInstance vs getIntegerInstance I was indicating that I wished to include currency in the output...

Luke
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I wasn't paying enough attention. Yes, you did indicate you wished to include currency in the output. And it did. See the "$" at the beginning? Change from Locale.US to Locale.UK and you'll get the British pound symbol instead.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, that works as expected. What I was hoping to get though is USD appearing after the value. But it is possible that this can't be done using format alone.

Thanks,

Luke
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic