How do I format a number in Java?
What are the "Best Practices"?
Will I need to round a number before I format it?
32.302342342342343=>32.30
.7323=>0.73
etc.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From this thread, there are different ways to do this:
The DecimalFormat() seems to be the most dynamic way to do it, and it is also very easy to understand when reading others code.