Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
DrGenious
Creator
Creator

isNum

Hi,

 

I am trying to parse a file and I wrote in tjavarow component this line( boolean numeric = isNumeric(input_row.Cell_Name); ) but it idoesnt run.

How can I convert this expression into order to see if it is numeric and store it into a variable? 

 

Thanks a lot.

Labels (2)
1 Solution

Accepted Solutions
cmendels
Contributor III
Contributor III

Talend has a routine Mathematical.NUM(input) that returns 1 if it's a numeric data type and 0 if not. Would that work?

View solution in original post

4 Replies
manodwhb
Champion II
Champion II

@DrGenious , you need to use something like below code.

 

public static boolean isNumeric(String strNum) {
    if (strNum == null) {
        return false;
    }
    try {
        double d = Double.parseDouble(strNum);
    } catch (NumberFormatException nfe) {
        return false;
    }
    return true;
}
DrGenious
Creator
Creator
Author

@manodwhb  Is not any simplier way? I dont want to declare it as a double , I want only to take the boolean result.

manodwhb
Champion II
Champion II

@DrGenious , you need to write specified java otherwise not sure.

 

cmendels
Contributor III
Contributor III

Talend has a routine Mathematical.NUM(input) that returns 1 if it's a numeric data type and 0 if not. Would that work?