To participate in the forums you have to register or login.

metamodel (#7) - Can't parse double from query (#112) - Message List

Can't parse double from query

I'm running a query, and one of the results I need is the double value 1.1. The value resides in a column which is of type VARCHAR (I used columns.getType() to find out the type)

However, after running the query, the output I get is 1,1

The decimal point is replaced with the comma. Is this because of the column type?

I'm printing out the value on the console using:

"System.out.println(dataset.getRow().getValue(0).toString());"

And I'm parsing the double using the Double.parseDouble() method.

Has this occurred to anyone before? I can provide the excel file if needed. I'm using MetaModel 1.2

  • Message #436

    Hi kshah,

    What is the type of value that you are getting? You can tell me this by running:

    System.out.println("I'm getting: " + dataset.getRow().getValue(0).getClass().getName());

  • Message #437

    I'm getting: java.lang.String

  • Message #438

    I was just investigating the code and it seems that all numeric values are passed through a number formatter and returned as a string in stead of as the "real" number-value. I guess we need to fix this as it's technically a bug.

    As a workaround you can use:

    NumberFormat nf = FormatHelper.getUiNumberFormat();
    Number number = nf.parse(dataset.getRow().getValue(0));
    
  • Message #439

    OK, works great. Thanks.