Guest User

Untitled

a guest
Oct 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. ValorCatastral = 35200000.873333333d;
  2. System.out.println("Valor Catastral del edificio: " + Math.floor(ValorCatastral) + "€");
  3.  
  4. import java.text.DecimalFormat;
  5. import java.text.DecimalFormatSymbols;
  6. import java.util.Locale;
  7.  
  8. public class Test {
  9.  
  10. public static void main(String[] args) {
  11.  
  12. String pattern = "###,###,###.## €";
  13. double value = 35200000.873333333d;
  14.  
  15. //Si no le paso ningun Locale, toma el del sistema, que en mi caso es Locale("es","MX");
  16. DecimalFormat myFormatter = new DecimalFormat(pattern);
  17. String output = myFormatter.format(value);
  18. System.out.println(value + " " + pattern + " " + output);
  19.  
  20. //Aquí se le pasa el default de Alemania
  21. myFormatter = new DecimalFormat(pattern,DecimalFormatSymbols.getInstance(Locale.GERMANY));
  22. output = myFormatter.format(value);
  23. System.out.println(value + " " + pattern + " " + output);
  24. }
  25.  
  26. }
Add Comment
Please, Sign In to add comment