I have a JTextField. I need to output there a double. Double is changing all the time (the program is a simple calculator). Possible options for the double are: 10.123, 22.1, 12.00023123, etc. The problem is that when I use String.format. it always gives me 5 decimal places after the "." Even if those are zeroes. Is there is a way to truncate those 0's when needed, but leave other numbers if any?
Thank you.
screen.setText(String.format("%10.5f", secondNumber));