Search code examples
javadoublebigdecimal

Convert string with more than 20 digits to a number using Java


I have this string:

0.023526112354180534 

How can I transform this string to number, and maybe more digits? I tried Double.parseDouble and not work

EDIT

You are right.

I´m making a call from Javascript and my call is:

url : "/myapp/data/selectedCampaign/thermal/"+data

data=0.023526112354180534

When I entered this method in Spring

@RequestMapping(value = "/selectedCampaign/{type}/{evidenceValue}", method = RequestMethod.GET)
    public @ResponseBody List<Double> getValues(@PathVariable("type") String type,
            @PathVariable("evidenceValue") String evidenceValue)

evidenceValue is 0 and I was parsing 0

I still don t know why. EDIT 2

I reolve this issue by going to:

Spring MVC @PathVariable with dot (.) is getting truncated


Solution

  • use new BigDecimal("0.023526112354180534");