I'm creating an app from java to print sales check:
Locale locale = new Locale("EN", "US");
NumberFormat formatter = NumberFormat.getCurrencyInstance(locale);
final private String contentTicket = "\n"
+ "_________________________________________\n"
+ "TOTAL: " + formatter.format(total) + "\n"
+ "PAY WITH: " + formatter.format(payWith) + "\n"
+ "CHANGE: " + formatter.format(change) + "\n"
+ "_________________________________________\n"
+ " Thank you, have a good day...!!\n"
+ "=========================================\n";
The problem that I have is the alignment when I use the locale formatter for the monetary values. For example I want the output result be like this:
_________________________________________
TOTAL: $5,000.00
PAY WITH: $10,000.00
CHANGE: $5,000.00
_________________________________________
Thank you, have a good day...!!
=========================================
But, I'm getting this:
_________________________________________
TOTAL: $5,000.00
PAY WITH: $10,000.00
CHANGE: $5,000.00
_________________________________________
Thank you, have a good day...!!
=========================================
The variables total
, payWith
and change
are all Double values.
Thanks in advance...