Java Currency Conversion Example

In this example we are going to implement Currency Conversion Using Java.

For converting money from one currency to another, we need to find the exchange rate between that currencies.

Mostly exchange rates are fluctuating in daily basis. Here we are using Yahoo Finance API online service for finding exchange rates

You can see more features about the API here -> http://finance.yahoo.com/currency-converter

Get/Find All Possible Currencies Using Java API

In this example we are generating all possible currencies using Java.

Locale.getAvailableLocales()

The method Locale.getAvailableLocales() returns the array of Locale values. We can iterate this array of Locale and able to view the different countries available as per the Locale.

We can also use Currency.getInstance(locale).getCurrencyCode() method to find the currency code for each country

How To Generate UUID In Java

In this example we are generating UUID using java API. We can use this java API if your JDK is above 1.5.

Following are the important methods avaialbe on UUID class

Note String toString(), This method will returns a String object representing this UUID.
int variant(), This method will returns the variant number associated with this UUID.
int version(), This method will returns the version number associated with this UUID.

Reference -> http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html

Create Thread In Java Web Application

Create Thread In Java Web Application explains about implementing a background thread in a java web application so that you can do some logic behind these background thread.

You can achieve thread implementation in j2ee web application several ways. For example if you are using application servers like Jboss,Weblogic & Websphere, you have more possible ways to do this. But here we are targeting for both servlet containers like Tomcat, jetty etc and application servers like JBOSS, Weblogic etc.

Evaluate/Check List/Collection Is Empty In JSTL

Evaluate/Check List/Collection Is Empty In JSTL explains about How to evaluate whether a List or Collection is empty using JSTL empty operator.

Consider the example here, a JSP page which contains a HashMap with lot of key value pairs in it and we need check this list is empty or not

For evaluating a Collection is empty or not inside JSTL, we can use empty operator. By using this operator we can check Collection is empty or not

Java 8 Encode/Decode base64 Example

Java 8 Encode/Decode base64 Example explains about encoding and decoding of a Base64 string using java 8

I have already wrote an article Encode And Decode In Base64 Using Java before 3 years, about encoding/decoding base64 formatted string using different java third party api's. This is because in that days, there is no decent api is available for encode/decode a string into base64

Finally Java 8 included new feature to encode/decode base64 string without the help of any third party libraries

JSTL Size Of Map

JSTL Size Of Map explains about how to find the size of a map using JSTL Taglib

Consider the example here, a JSP page which contains a HashMap with lot of key value pairs in it and we need to find the size of this HashMap

We already seen how to find the size of a Collection using the JSTL fn:length function.

You can see it fn:length() JSTL Function .

JoSQL tutorial

JoSQL (SQL for Java Objects) provides the ability for a developer to apply a SQL statement to a collection of Java Objects. JoSQL provides the ability to search, order and group ANY Java objects and should be applied when you want to perform SQL-like queries on a collection of Java Objects.

As a developer, JoSQL (SQL for Java Objects) helps us to perform sql queries in collection of in-memory java objects.

We can perform following operations using JoSQL

1) where 2) like 3) group by 4) order by 5) limit 6) between

Referenece - > http://josql.sourceforge.net/