![JAR search and dependency download from the Maven repository](/logo.png)
com.github.TKnudsen.ComplexDataObject.model.tools.StringUtils Maven / Gradle / Ivy
package com.github.TKnudsen.ComplexDataObject.model.tools;
/**
*
* Title: StringUtils
*
*
*
* Description: little helpers when working with String.
*
*
*
* Copyright: Copyright (c) 2017
*
*
* @author Juergen Bernard
* @version 1.01
*/
public class StringUtils {
public static String truncateDouble(double value, int decimals) {
if (decimals < 0)
return null;
String result = (new Double(value)).toString();
int dot = result.lastIndexOf(".");
int length = result.length();
result = result.substring(0, (int) (Math.min(dot + 1 + decimals, length)));
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy