[resolved] Convert a String to Long

One Star

[resolved] Convert a String to Long

I setting a variable as
Long.parseLong(row1.precio.trim())
but released the following exception...
Exception in component tMap_1
java.lang.NumberFormatException: For input string: "100.00"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at tabd.importprices_0_1.ImportPrices.tFileInputExcel_1Process(ImportPrices.java:934)
at tabd.importprices_0_1.ImportPrices.runJobInTOS(ImportPrices.java:1286)
at tabd.importprices_0_1.ImportPrices.main(ImportPrices.java:1195)
OS: Win XP SP3
TOS: 3.1.3

Accepted Solutions
Community Manager

Re: [resolved] Convert a String to Long

Hello
You should substring the string if there is a period? for example:
row1.precio.contains(".")?row1.precio.substring(0,row1.precio.indexOf("."):row1.precio
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Convert a String to Long

Hello
You should substring the string if there is a period? for example:
row1.precio.contains(".")?row1.precio.substring(0,row1.precio.indexOf("."):row1.precio
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Convert a String to Long

It´s working.
Thank you