fork(4) download
  1. import java.text.DecimalFormat;
  2. import java.text.DecimalFormatSymbols;
  3. import java.text.NumberFormat;
  4. import java.util.Locale;
  5.  
  6. class Ideone {
  7. public static NumberFormat seuFormato() {
  8. symbols.setDecimalSeparator(',');
  9. symbols.setGroupingSeparator('.');
  10. return new DecimalFormat("#0.00", symbols);
  11. }
  12.  
  13. public static void main(String[] args) {
  14. NumberFormat formatter = seuFormato();
  15. float a = 5;
  16. System.out.println(formatter.format(a));
  17. }
  18. }
Success #stdin #stdout 0.12s 321152KB
stdin
Standard input is empty
stdout
5,00