• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Is there a library that deals with currency?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm really new to Java and was wondering if there was a library in the API that deals with currency that could be used in monetary calculations or conversions?
 
Marshal
Posts: 61693
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Difficult to be sure what you require. There is a Currency class, and up to J2SE1.4 you would have used DecimalFormat to print the result. Nowadays, you would use the formatting tags in System.out.printf for formatting; there are more details in the Formatter class API. You would use the BigDecimal class to do any arithmetic. Have a look at the Java Tutorial about formatting and currency.

And I hope that lot is of some help to you.

CR
 
Debi Manson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! That's just what I needed.
 
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Debi Manson:
if there was a library in the API that deals with currency that could be used in monetary calculations or conversions?



bless you for not using Floating Point for currency.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also check out the JScience library. In addition to supporting currencies it also supports a wide variety of unit and unit conversions (it's a reference implementation of JSR-275). Check out the API for more details.

Dave
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!