Solved

Convert String to Double

Posted on 2001-07-05
7
1,330 Views
Last Modified: 2008-02-26
Hi all,
 I am using JSP  and i need to convert string to double

Double.valueOf(mystring)  does not work..
 Any suggestion will be appreciated.
 
0
Comment
Question by:camasuvi
7 Comments
 
LVL 1

Expert Comment

by:gtloafer
ID: 6254708
how about use the constructor Double(String)  in class Double ?

0
 

Author Comment

by:camasuvi
ID: 6254713
you mean
double newValue = Double(myString)   ?
0
 
LVL 1

Expert Comment

by:gtloafer
ID: 6254721
Well not quite ....rather I was thinking like this :-

Double dWrap = new Double("200");
double dVal = dWrap.doubleValue(); //this is because dWrap is an object wrapper for the primitive type double ..


regards gtloafer
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 1

Expert Comment

by:gtloafer
ID: 6254723
by the way what kind of string value are you passing ? ..Just curious thats why :-)

regards gtloafer
0
 
LVL 1

Expert Comment

by:poluru
ID: 6254742
hi,
Double.valueOf(myString).doubleValue();
its working nice...i have used it many times.
why its not working ??? just try once again...
0
 
LVL 1

Accepted Solution

by:
shahnazali earned 240 total points
ID: 6254769
use static method of Double
 double Double.parseDouble ( String s )

if u r not sure about your string that it contains double format number , catch NumberFormatException .

bye.

0
 

Expert Comment

by:anhphuongnn
ID: 6268553

Hi,

You can try this code. is it you need?

import java.io.*;
import java.lang.*;

public class StringToDouble {
  static void main(String agrs[]) {
        Object obj = new Double("1.101");
        System.out.println("test"+obj.toString());
  }

}


Best Regard

PhuongNguyen
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question