Monday, 2 March 2020

How to set decimals to only 2 digits in Doubles?

 When you want set double value only two digit after decimal. just follow the below process for android using java or also using kotlin

double time = 200.3456;
DecimalFormat df = new DecimalFormat("#.##");     
time = Double.valueOf(df.format(time));


Thanks