alexa

How to truncate decimal value in a text in android ?

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);

285 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry