java string format 2 digits after decimal code example Example: java string format .2f String.format("%.2f", 3.45);