I am trying to print out a double that is always 4 digits as well as has 2 decimal places.
For example, If the number was 105.456789
my String.Format
would print out 0105.45
I understand that %.2f
allows for the two decimal place problem.
I also understand that %04d
allows for the 4 digit problem
However, I cannot for the life of me figure out how to combine the two.
I have tried doing a double String.format
I have tried doing one String.format
and using both %04d
and %.2f
System.out.println(String.format("Gross Pay: $%.2f %04d", 105.456789));
I expect the output to be 0105.45 but I can't even get it to compile