Parsing Text to number and back again.

How to Convert from a String to a Number:
I for one can never remember easily how to parse strings to numbers and back so here are a few reminders on how to easily do that.

Parsing a String to an Integer:
Integer i = Integer.parseInt( '37.08' )

Parsing a String variable to an Integer:
String str = '37.08' Integer i = Integer.parseInt(str.trim) ''Note: It is very import to use .trim when using a string variable to ensure there is no trailing white space. Doing this will ensure that it does not make things difficult later one.''

Parsing a String to a Double:
Double d = Double.parseDouble( '37.08' )

Parsing a String variable to an Double:
String str = '37.08' Double d = Double.parseDouble(str.trim) ''Note: It is very import to use .trim when using a string variable to ensure there is no trailing white space. Doing this will ensure that it does not make things difficult later one.''

How to Convert from an Integer to a String:
This is how we convert back from an integer to a string.

Parsing a Integer to a String:
int i = 1 String str = Integer.toString( i )

Parsing a Double to a String:
Double d = 1 String str = Double.toString( d )