Currency Conversion in ADF using Google Calculator API integration

Sharing is Caring

First, thanks to this post
I was looking for an API or web service for retrieving live currency fluctuation, finally, I came to this solution that integrates Google Calculator with Java to calculate live currency conversion rates and I have integrated this with my Oracle ADF Application

I have created an application using bounded task flow –

  • Created a .jsff page with two input text, to get the value of Base and Term currency and a button, on the basis of both values currency conversion rate will be calculated
  • In order to use Google Calculator, we have to use GSON (open source Java library (API) to convert JSON objects in POJO (pure java object))
  • To access GSON library we have to add google-gson-stream-2.2.1.jar in our project library – Download Gson Jar
  • This trick uses google calculator for calculating conversion rate, as we all know Google Calculator is very smart, whenever we search like 1 USD, it always shows results according to locale

As 1 USD searched in India-

As 1 USD searched in the UK- 

  • This is also hidden benefit for our application, we can pass locale to get changed values also- now see what is the code that gets values from Google Calculator
   public void calculateFluctuationButton(ActionEvent actionEvent) throws Exception {  
     String google = "";  
     /**Get values from page component binding*/  
     String baseCurrency = baseCurrencyBind.getValue().toString();  
     String termCurrency = termCurrencyBind.getValue().toString();  
     String charset = "UTF-8";  
     /**Replace url using your values-*/  
     URL url = new URL(google + baseCurrency + "%3D%3F" + termCurrency);  
     /**Go to url directly to see you result*/  
     Reader reader = new InputStreamReader(url.openStream(), charset);  
     Result result = new Gson().fromJson(reader, Result.class);  
     // Get the value without the term currency.  
     String amount = result.getRhs().split("\s+")[0];  


  • See in the code I have passed currency notation from the page (INR, USD ) to bean and passed it in URL of google calculator. This URL returns current currency conversion rate.
Currency Conversion

Download Complete Application –Sample ADF Application

Cheers 🙂 Happy Learning

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *