If you are sure that the double is indeed an integer use this one:

NumberFormat nf = DecimalFormat.getInstance();
nf.setMaximumFractionDigits(0);
String str = nf.format(documentNumber);

As a bonus, this way you keep your locale's configuration as in thousand separator.

EDIT
I add this previously removed option as it seems that was useful to the OP:

Double.valueOf(documentNumber).intValue();
Answer from Paco Abato on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java numbers › convert double to string, removing decimal places
Convert Double to String, Removing Decimal Places | Baeldung
January 8, 2024 - We’ll look at how to do it when we want to just truncate the decimal part and when we want to round it. If our double value is within the int range, we can cast it to an int. The cast truncates the decimal part, meaning that it cuts it off ...
Discussions

How to remove decimal values from a value of type 'double' in Java - Stack Overflow
I am invoking a method called "calculateStampDuty", which will return the amount of stamp duty to be paid on a property. The percentage calculation works fine, and returns the correct value of "150... More on stackoverflow.com
🌐 stackoverflow.com
Java Double to String conversion without formatting - Stack Overflow
I have the number 654987. Its an ID in a database. I want to convert it to a string. The regular Double.ToString(value) makes it into scientific form, 6.54987E5. Something I dont want. Other form... More on stackoverflow.com
🌐 stackoverflow.com
converting Double to string
string() doesn't convert a double to a string in the string manipulator node. When I try use a Double.ToString in a Java Snippet it gives me a non-recurring decimal. When I use a groupby and concatenate it does the same. Is there anyway around this? Thank you Varun More on forum.knime.com
🌐 forum.knime.com
0
0
May 9, 2014
How to convert string to double without losing precision after decimal point?
The short answer is that you can’t. The long answer is that 5.0 and 5.00000 are the same thing. Internally double has more precision, but when you print a double it only prints with the amount of precision you need. The answer is to print the decimal with a format string as shown in the second line below. Double number = Double.parseDouble(“5.00000”); System.out.printf(“%.5f”, number); That second line says print a formatted string, % means print a variable, .5 means print 5 decimal places, f means the variable is floating point, and number is just the variable that stores your number. More on reddit.com
🌐 r/javahelp
8
4
July 21, 2021
People also ask

How can I control the number of decimal places when converting a double to a string in Java?
You can use the String.format() method or DecimalFormat.format() method to control the number of decimal places.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › convert double to string in java
Turning Double into String: Java Techniques
What's the difference between using String.valueOf() and Double.toString() when converting a double to a string in Java?
Both String.valueOf() and Double.toString() methods can convert a double to a string in Java, and they produce the same result. The main difference lies in the method they belong to. The former is a method of the String class, and the latter is a method of the Double class.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › convert double to string in java
Turning Double into String: Java Techniques
How does Java handle the conversion of a negative double to an int?
When a negative double is cast to an int in Java, the value is truncated, not rounded. This means it simply discards the decimal part. For example, if you cast -123.456 to an int, you'll get -123.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › convert double to string in java
Turning Double into String: Java Techniques
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › convert double to string in java
Turning Double into String: Java Techniques
2 weeks ago - This output shows that the double value 123.456 has been converted to a String without any decimal points. In Java, you can convert a double to an int simply by using casting.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-convert-double-to-string
Java Convert double to String | DigitalOcean
August 3, 2022 - This is the easiest way to convert double to string in java. double d = 123.45d; String str = d+""; // str is '123.45' We can use Double class toString method to get the string representation of double in decimal points.
🌐
Scaler
scaler.com › home › topics › convert double to string in java
Convert double to String in Java - Scaler Topics
January 11, 2024 - Java program can be converted from double to string using the String.format() method. It is used to represent double as a string with a specified number of digits after the decimal and rounded values to decimal places.
Find elsewhere
🌐
KNIME Community
forum.knime.com › knime analytics platform
converting Double to string - KNIME Analytics Platform - KNIME Community Forum
May 9, 2014 - string() doesn't convert a double to a string in the string manipulator node. When I try use a Double.ToString in a Java Snippet it gives me a non-recurring decimal. When I use a groupby and concatenate it does the same…
🌐
Reddit
reddit.com › r/javahelp › how to convert string to double without losing precision after decimal point?
How to convert string to double without losing precision after decimal point? : r/javahelp
July 21, 2021 - This isn't a matter of losing or gaining precision in the actual number, it is simply a matter of padding out the zeroes in the String representation. ... You are approaching this at the wrong end. Don't look for the number of digits in the data type. Set them when you output (print) the value. Look into Formatter and System.out.printf ... u/desrtfx is correct. That simply isn't how doubles work. See this article for more information about how doubles (and floats) are stored in Java: https://en.m.wikipedia.org/wiki/IEEE_754
🌐
C# Corner
c-sharpcorner.com › blogs › convert-and-display-double-value-as-string-in-java
Convert and Display Double Value as String in Java
September 4, 2024 - int count = 10; // Example count value double nota = count * 0.25; txtNota.setText(Double.toString(nota)); ... If count = 10, then nota = 10 * 0.25 = 2.5. The text field txtNota will display 2.5. Java uses the default locale for number formatting, which might result in different decimal separators (e.g., a comma instead of a period in some locales). To explicitly control the format, you can use String.format with a specified Locale.
🌐
The Coding Forums
thecodingforums.com › archive › archive › java
Clean way to write Double into String without the trailing ".0" ? | Java | Coding Forums
December 23, 2009 - Easy newbie-question here for the experts: What's a clean way of writing a Double into a String, avoiding the ".0" at the end ? The Double.toString() method insists on appending a decimal fraction ".0" no matter what, and I only want the fractions ...
🌐
Coderanch
coderanch.com › t › 572477 › java › DecimalFormatting-remove-decimal-point
DecimalFormatting to remove decimal point (Java in General forum at Coderanch)
Hi ya, Thanks for that, I tried this but I think I may have got the right idea, it still leaves the decimal point on: ... I've overlooked the Double.valueOf(...).toString() in your code. You need to drop this. Just return the output of the formatter from your method. (You're converting the formatter's output back to Double and then to String again, which imposes further unwanted conversions.)
🌐
CodeGym
codegym.cc › java blog › java numbers › java convert double to string
Java Convert Double to String
September 28, 2023 - Vernier Calliper Double: 7.271572353580126 Vernier Calliper String: 7.271572353580126 · By now, you must be familiar with different ways of converting the Java double to string. But in order to master anything, practise is the key.
🌐
Java67
java67.com › 2015 › 06 › how-to-convert-string-to-double-java-example.html
How to convert String to Double in Java and double to String with Example | Java67
The second method is mainly for the Double objects, but don't worry even if you have a double value you can leverage autoboxing to first convert it into a Double object and then just call the toString() method on it to get an equivalent String ...
🌐
Java67
java67.com › 2014 › 06 › how-to-format-float-or-double-number-java-example.html
5 Examples of Formatting Float or Double Numbers to String in Java | Java67
You often need to pretty print ... Java provides lots of convenient methods to format a floating point number up to certain decimal places. For example you can use method printf() to format a float or double number to a output stream. However, it does not return a String...
🌐
BeginnersBook
beginnersbook.com › 2015 › 05 › java-double-to-string
Java – Convert double to string example
November 14, 2016 - import java.text.DecimalFormat; public class JavaExample{ public static void main(String args[]){ double dnum = -99.999; /* creating instance of DecimalFormat * #.000 is to have 3 digits after decimal point * in our output string */ DecimalFormat df = new DecimalFormat("#.000"); //conversion String str = df.format(dnum); //displaying output System.out.println("My String is: "+str); } }
🌐
Baeldung
baeldung.com › home › java › java numbers › print a double value without scientific notation in java
Print a Double Value Without Scientific Notation in Java | Baeldung
December 28, 2023 - Subsequently, the toPlainString() function converts our complex object into a printable string, providing a precise and easily interpretable representation. Besides eliminating scientific notation, BigDecimal provides features such as customizable ...