Home:ALL Converter>Converting from XMLSchema datatype to Java int

Converting from XMLSchema datatype to Java int

Ask Time:2012-04-11T02:11:22         Author:Prerak Pradhan

Json Formatter

I am working on a project that involves fetching data from Dbpedia and I was wondering whether there is anyway to convert the the object returned from a dbpedia query i.e a XMLSchema#double into a java int so that I can perform operations on it and modify the data for my use. I am using jena to fetch the data from the sparql endpoints jena provide. I tried using the toString method to change the RDFnode into a string and than converting into an int/double, but that doesnt seem to work and gives me the exception that is listed below:

Exception in thread "main" java.lang.NumberFormatException: For input string: "147181000000^^http://www.w3.org/2001/XMLSchema#double"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

Does anyone here have a work around this problem??

Author:Prerak Pradhan,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/10094126/converting-from-xmlschema-datatype-to-java-int
yy