Content received from: http://JavaFAQ.nu/java-article115.html
I am reading my values from a db which is supposed to be a string, but sometime Monday, April 28, 2003 (00:00:00)
Posted by jalex
Question: I am reading my values from a
db which is supposed to be a string, but sometime they can be doubles or
something else...
How could I check if a string was double?
Answer: You can try to try to parse the
String into a double and catch the exception:
String mystr="1.6";
try {
Double dbl = new Double(s);
// do smth. here}
catch (NumberFormatException ex) {
// d smth. else here
}
***************************************
Our older tips: March 22, 2001 - October 21, 2002
read here.
All published and not published on site tips you can find
here
|