1i will refer this site just read it and you will understand everything
2i hope this help:https://zetcode.com/java/numberformat/
1double value = 4.2352989244d;
2String.format("%.2f", value) //output "4.24");
3String.format("%.3f", value)//output("4.235");