I have a ResultSet that i iterate over and i create a report like view (html).
The problem is that some columns return Long values (as a result of mathematical function in SQL).
Is there an easy way that I can identify this values by DataType?
Lets say i want to do something like this
String x = rs.getString(1);
if(MyUtilClass.isOfTypeLong(x)){
//implement my bussiness logig
}
I have seen this post How do you determine the type of data contained in a string? . If there isn’t anything better right now, I will proceed with the regEx solution.
Why don’t you try
Long.valueOf(String)to first parse it as aLong, and failing that parse it as aDoublewithDouble.valueOf(String)?Both throw a
NumberFormatExceptionif the string cannot be parsed.