Currency… Not as easy as you think

I had to implement a bunch of currencies as a part of my work. When I said a bunch, I meant all the currencies in the world. The task, though initially seemed like a no-brainer, turned out the be the most tiring and mundane one. I thought I would share how unexpected the task turned out to be.

Firstly, it took me days to come up with enough data to sort out the important currencies from the slightly less important one depending on our customer base. Secondly, I realised that not all currencies have two decimal places(Yes, I know, this should have come first). Thirdly, I realised that things like the currency symbol, the currency symbol’s unicode, the currency pattern, the country the currency is used in and the at last the official language of the country where it is used in were all required to implement the same. And lastly comes the unit testing. Checking and double checking if all the data I had was correct and then checking if the implementation was correct.

Seems to be too big, doesn’t it? Oh wait, I am not done yet. After implementing, rendering them using the correct font was the tricky part. With some help I was able to manage that.

You might wonder why I had to collect so much information just for a currency symbol and why collecting all the information was so tough. Even though we use money all over the world for transactions, there are still some confusions regarding the same and, a collection of all the details regarding a currency is very hard to get. JAVA makes it even more harder since it takes the “lc_id” as input and not the ISO code.

We use the currency symbol to personalise the user’s experience, but is it worth the trouble? Because, in the end, it is the ISO code that will be used for the transactions to indicate the currency.