Friday, January 10, 2014

Currency data type in Java, Mysql and Oracle

Initially I had no intention of writing this post till I saw a friend of mind in a total mess. When dealing with financial applications data type is a key thing to be careful with. So far I have written many financial applications especially for accounts using java, mysql and oracle and would like to share my experience with you. I won't talk much because I am pragmatic and like going straight to the point.

Java: BigDecimal
Mysql: NUMBER (19,2) 
OracleNUMBER (19,2)
Exchange rate: NUMBER (19,4)
Rounding: .setScale(2,RoundingMode.HALF_EVEN) 

If you have been around this for a while the above five lines will be your key to heaven.
Don't hesitate to throw some comments.

 

No comments:

Post a Comment