You can use Double.parseDouble() to convert a String to a double:

String text = "12.34"; // example String
double value = Double.parseDouble(text);

For your case it looks like you want:

double total = Double.parseDouble(jlbTotal.getText());
double price = Double.parseDouble(jlbPrice.getText());
Answer from WhiteFang34 on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
October 20, 2025 - Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string. The string is converted to a double value as if by the valueOf method. ... NumberFormatException - if the string does not contain a parsable number.
🌐
GeeksforGeeks
geeksforgeeks.org › java › double-parsedouble-method-in-java-with-examples
Double parseDouble() method in Java with examples - GeeksforGeeks
July 11, 2025 - // Java Code to implement // parseDouble() method of Double class class GFG { // Driver method public static void main(String[] args) { try { String str = ""; // returns the double value // represented by the string argument double val = Double.pa...
Discussions

[Java] What's Double.parseDouble and how do I go about using it?
Double.parseDouble converts a string into a double, or throws a NumberFormatException if the string does not represent a double. e.g. Double.parseDouble("3.14") returns the double 3.14. All of Java's numeric types have a corresponding parse function that takes a string and returns its numeric value. e.g. Integer.parseInt("12345") returns the int 12345. This is similar to C++'s atof and atoi functions. More on reddit.com
🌐 r/learnprogramming
4
3
October 24, 2012
I want to parse a string and get a double value (java) - Stack Overflow
I want to parse a string and get a double value. For example, I input "65.2 hello". More on stackoverflow.com
🌐 stackoverflow.com
Will Double.parseDouble always return the same exact value?
http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#valueOf(java.lang.String) It appears so. First, the string is converted to an imaginary "infinitely precise" representation, and then rounded via the IEEE floating point specification to a double. That sounds like a pretty deterministic algorithm to me. More on reddit.com
🌐 r/java
10
11
September 21, 2014
Port of Lemire's Double parser is more than 4X faster than openjdk double parser
I wish these parsers would give an option to tryParse returning an Optional instead of throwing. When speed is a goal, sometimes there are datasets that have a mix of strings and doubles. In that case, the cost of exceptions is very high in Java. Speaking from experience, needing to write a regex to precheck a double before parsing it, which is less expensive than exceptions.. More on reddit.com
🌐 r/java
48
125
October 29, 2020
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java double parsedouble method
Java Double parseDouble Method
September 1, 2008 - The Java Double parseDouble(String s) method returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
🌐
Stack Overflow
stackoverflow.com › questions › 72652140 › i-want-to-parse-a-string-and-get-a-double-value-java
I want to parse a string and get a double value (java) - Stack Overflow
double · java.util.scanner · Share · Improve this question · Follow · edited Jun 17, 2022 at 0:06 · user207421 · 312k4545 gold badges324324 silver badges493493 bronze badges · asked Jun 16, 2022 at 21:37 · Kristina · 4,71255 gold badges2424 silver badges3737 bronze badges 2 · 4 · hello obviously isn't a numerical value. You could use a second Scanner to parse the line of text or you could split the string on the white space or handle the exception ·
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-convert-string-to-double
Java Convert String to double | DigitalOcean
August 3, 2022 - We can convert String to Double object through it’s constructor too. Also if we want double primitive type, then we can use doubleValue() method on it. Note that this constructor has been deprecated in Java 9, preferred approach is to use parseDouble() or valueOf() methods.
🌐
Michael Fullan
michaelbfullan.com › home › the limitations of double.parsedouble()
The Limitations of Double.parseDouble() - Michael Fullan
February 1, 2021 - When using parseDouble, a String ending with one of these specifiers will parse without error. Even though it won’t break anything, seeing something like 10F in a GUI is probably not what you want. After reading what happens with format specifiers, you may be worried about underscores as well. Legal since Java 7, underscores can be used when defining numeric literals. They have no effect on the value, but can make them much easier to read if used with discretion. public static final double AVOGADROS_NUMBER = 6.022_140_857e23;
🌐
LabEx
labex.io › tutorials › java-java-double-parsedouble-method-117627
double.parsedouble in Java | LabEx
Java parseDouble() method is used to convert string values to their equivalent double values. This is an important method when it comes to data type conversion.
🌐
dale lane
dalelane.co.uk › blog
Avoiding monitor contention in Java's Double parseDouble
December 1, 2013 - There will be times when my double parser returns a number that isn’t exactly what Java’s Double.parseDouble would’ve returned. But the differences are going to be very small – they’ll round to the same value.
🌐
Coderanch
coderanch.com › t › 595201 › java › parse-Double-parseDouble
What is parse? (Double.parseDouble();)? (Beginning Java forum at Coderanch)
I pasted the whole code just in case. public static void main(String[] args) { Scanner keyboard; keyboard = new Scanner(System.in); boolean userContinue = true; String userInput; int count = 0; double sum = 0; double average = 0; while (userContinue) { System.out.println("Enter a number or Q to quit"); userInput = keyboard.next(); if (userInput.toLowerCase().equals("q")) { userContinue = false; } else { sum += Double.parseDouble(userInput); count += 1; } } // end of the while average = sum / count; System.out.printf("The average is %f\n", average); } // end of main Thank you!!
🌐
Baeldung
baeldung.com › home › java › java numbers › check for null before calling parse in double.parsedouble
Check for null Before Calling Parse in Double.parseDouble | Baeldung
August 28, 2025 - In this section, we’ll take a look at several options to check for null or empty values using core Java. Let’s start by defining a simple method that will check if the value we pass is null or an empty String: private static double parseStringToDouble(String value) { return value == null || value.isEmpty() ?
🌐
Coderanch
coderanch.com › t › 729127 › java › Double-parseDouble-sc-nextLine-don
d = Double.parseDouble(sc.nextLine()); I don't understand this line of code (Beginning Java forum at Coderanch)
April 11, 2020 - So Double,parseDouble( Strikng string ) is invoking the Double class static method which takes a String as its argument and returns a double value if the string can be interpreted as representing a double value, or it throws an exception if the string does not represent a double value.
🌐
Baeldung
baeldung.com › home › java › java string › convert string to double in java
Convert String to Double in Java | Baeldung
January 8, 2024 - In conclusion, Java provides us with multiple methods to convert Strings into double values. In general, we recommend using Double.parseDouble unless a boxed Double is needed.
🌐
W3Schools
w3schools.com › java › java_type_casting.asp
Java Type Casting
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... Type casting means converting one data type into another. For example, turning an int into a double.
🌐
Coding Strain
codingstrain.com › home › java miscellaneous tips › java double: parse string with comma
Java Double: Parse String with Comma -
July 19, 2025 - You can find the code fragments used in this post in the following GitHub project: java miscellaneous tips. In the simplest scenario, we have a number represented as a string in which the only peculiarity is the use of a comma instead of a point as a decimal separator. In this case, we can simply replace the occurrence of the comma with a point, using the String replaceAll method, as in the following example. String numStr = "121,234"; Double doubleNum = Double.valueOf(numStr.replaceAll(",", ".")); System.out.println(doubleNum);
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Double.html
Double (Java SE 17 & JDK 17)
January 20, 2026 - ... Deprecated, for removal: This API element is subject to removal in a future version. It is rarely appropriate to use this constructor. Use parseDouble(String) to convert a string to a double primitive, or use valueOf(String) to convert a string to a Double object.
🌐
Java Guides
javaguides.net › 2024 › 06 › java-double-parsedouble-method.html
Java Double parseDouble() Method
June 17, 2024 - The parseDouble() method can be used to convert valid numerical strings to double values.
🌐
Quora
quora.com › What-does-parseDouble-args-0-do-in-Java
What does parseDouble (args[0]) do in Java? - Quora
Answer (1 of 5): This is the typical statement that will determine an exception in perfectly legal situations. Normally the main method signature of a class is [code]public class MyClass { public static void main(String[] args) { } } [/code]This static function is the entry point of the [c...
🌐
Mkyong
mkyong.com › home › java › java – convert string to double
Java – Convert String to double - Mkyong.com
May 3, 2019 - In Java, we can use Double.parseDouble() to convert a String to double · Example to convert a String 3.142 to an primitive double. String str = "3.142"; double pi = Double.parseDouble(str); System.out.println(pi); Output · 3.142 · Example ...