• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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: 59762
188
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!