What is the language? Java? You can use the split() function of String if you just want to keep numbers before "." :

String mystring = "34.000000";
String correctstring[] = mystring.split(".");
System.out.println(correctstring[0]);
// display : 34

it will delete all digits after "." !

Answer from Crow EH on Stack Overflow
🌐
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.)
🌐
Quora
quora.com › How-do-I-cut-off-decimals-in-Java
How to cut off decimals in Java - Quora
Answer (1 of 3): Use a [code ]double[/code], or a [code ]BigDecimal[/code] if more appropriate, to represent your actual number. Use [code ]NumberFormat[/code] to format it for “human-readable” display. Assuming that the reason you want to “cut off decimals” is purely for human-facing ...
🌐
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 - The cast truncates the decimal part, meaning that it cuts it off without doing any rounding. This approach is about 10 times as fast as the other approaches we’ll look at. Once it’s an int, then we can then pass it to the valueOf method on the String class:
🌐
Java Code Examples
javacodeexamples.com › home › java regex – remove decimal part from the number
Java RegEx - Remove Decimal Part From the Number - Java Code Examples
August 3, 2021 - In order to remove the decimal point and trailing decimal parts or trailing zeros, we need to use the replaceAll method along with the regex pattern. We are going to replace the matching text with the empty string to remove it from the number.
🌐
Bytes
bytes.com › home › forum › topic › java
Removing decimal points - Java
September 10, 2008 - http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
🌐
Quora
quora.com › How-can-I-remove-numbers-more-than-2-decimal-places-in-string
How to remove numbers more than 2 decimal places in string - Quora
Answer (1 of 3): Well, you could first convert it to a numeric value, round it off, and then change it to a string again. If that is infeasible for some reason, there is another thing you could try.
Find elsewhere
🌐
ServiceNow Community
servicenow.com › community › developer-forum › how-to-remove-decimal-from-the-string-field-in-the-server-side › m-p › 1760697
Solved: how to remove decimal from the string field in the... - ServiceNow Community
September 22, 2021 - For the other suggestion below, by the other poster, with using Math.round, that is also a viable option...if...you want to actually round the integer. If you're simply wanting to chop off the decimal and any digit thereafter, with no rounding, then what I've mentioned above will do that.
🌐
Coderanch
coderanch.com › t › 627386 › java › Decimal-point-remove
Decimal point remove (Beginning Java forum at Coderanch)
January 22, 2014 - Thanks for the help. I have removed leading zeros using DecimalFormat. ... Shiva Mohan wrote:If I have 0123.45 string and trying to get 12345 as result. I am trying regex like below. String s="0123.45"; s = s.replaceAll("^0*([0-9]+).*", "$1"); It gave result 123 as leading zeros removed that is one of the things that I want.
🌐
Stack Overflow
stackoverflow.com › questions › 20504526 › removing-a-decimal-point-in-java
Removing a decimal point in java - Stack Overflow
Even if the user enters a number without a decimal, it will keep it as such. double x = 11.45; // number inputted String s = String.valueOf(x); // String value of the number inputted int index = s.indexOf("."); // find where the decimal is located int amount = (int)x; // intialize it to be the number inputted, in case its an int if (amount != x) // if the number inputted isn't an int (contains decimal) // multiply it by 10 ^ (the number of digits after the decimal place) amount = (int)(x * Math.pow(10,(s.length() - 1 - index))); System.out.print(amount); // output is 1145 // if x was 11.4500, the output is 1145 as well // if x was 114500, the output is 114500
🌐
javaspring
javaspring.net › blog › java-string-remove-all-non-numeric-characters-but-keep-the-decimal-separator
How to Remove Non-Numeric Characters from a Java String While Keeping the Decimal Separator — javaspring.net
StringUtils is convenient but adds a dependency. Use this if your project already includes Apache Commons Lang. Many locales use , as the decimal separator (e.g., French: 123,45 instead of 123.45). To make your solution locale-aware: Use DecimalFormatSymbols to fetch the decimal separator for a given locale: import java.text.DecimalFormatSymbols; import java.util.Locale; public class LocaleExample { public static char getDecimalSeparator(Locale locale) { DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); return symbols.getDecimalSeparator(); } public static void main(String[] args) { Locale frenchLocale = Locale.FRENCH; char decimalSep = getDecimalSeparator(frenchLocale); System.out.println(decimalSep); // Output: ',' (French uses ',' as decimal) } }
🌐
Experts Exchange
experts-exchange.com › questions › 24499850 › Java-remove-String-leading-and-trailing-zero-and-decimal-point-if-it-is-on-the-last-position.html
Solved: Java remove String leading and trailing zero and decimal point if it is on the last position? | Experts Exchange
November 23, 2013 - This program works to remove the leading and trailing zeros from the given String, I also want to remove the decimal point if it is on the last position. for instance, the string is ended up like 100. or 298. after the trailing zeros are removed. I want the final string looks like 100 or 298 instead of 100. or 298. public class TrimZeros { private static java.lang.String removeLeadingZeros( java.lang.String str ){ if (str == null){ return null;} char[] chars = str.toCharArray(); int index = 0; for (; index < str.length();index++) { if (chars[index] != '0'){ break;} } return (index == 0) ?
🌐
Baeldung
baeldung.com › home › java › java string › retain only digits and decimal separator in string
Retain Only Digits and Decimal Separator in String | Baeldung
January 18, 2024 - To remove all non-numeric characters but keep the decimal separator in a Java String using Guava, we’ll use methods from the CharMatcher utility class.
🌐
CopyProgramming
copyprogramming.com › howto › how-to-remove-decimal-places-java-code-example
Java: Java Code Example for Removing Decimal Places
May 31, 2023 - Java how to remove decimal places Code Example, String truncated = String.valueOf((int) doubleValue);