Tuesday, July 22, 2008

Converting a double to an int in Java

Today I needed to do something rather simple like converting a double (which will always be an int by practice) to an int. I did a search and found this page

and it gave me exactly what I needed. I have a String value which is stored as a number in oracle, but comes out of the BO with decimals.

Here's the code I ended up with:

(int)Math.round(Double.parseDouble((String)Config.getConfig("AO_ORDER_LKP_MAX_RECORDS")));


Not very pretty, but it does what I need.

No comments: