Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

How to truncate decimal value in a text in android ?

By M.K. Verma · 4 May 2022

How to truncate decimal value in a text in android ?

try this

String str = "10.289 Mbps";

String[] strArray = str.split(" ");
    
Long roundedValue = Math.round(Double.valueOf(strArray[0]));
    
String resultStr = roundedValue.toString() + " " + strArray[1];

System.out.println(resultStr);