fork download
  1. import java.text.*;
  2. import java.math.*;
  3. import java.util.*;
  4.  
  5. class Exemplo {
  6. public static void main(String[] args) {
  7. BigDecimal valor = new BigDecimal("100"); //idealmente deveria fazer parse formatado aqui também
  8. exemplo(valor);
  9. }
  10.  
  11. public static void exemplo(BigDecimal valor) {
  12. try {
  13. DecimalFormat df = new DecimalFormat("###,##0", new DecimalFormatSymbols (new Locale ("pt", "BR")));
  14. df.setParseBigDecimal(true);
  15. BigDecimal decimal = (BigDecimal)df.parse("50.000");
  16. if (valor.compareTo(decimal) == 1 || valor.compareTo(decimal) == 0) System.out.println("número maior");
  17. else System.out.println("número menor");
  18. } catch (ParseException e) { //só para facilitar, não faça isto
  19. e.printStackTrace();
  20. }
  21. }
  22. }
  23.  
  24. //https://pt.stackoverflow.com/q/120192/101
Success #stdin #stdout 0.09s 34956KB
stdin
Standard input is empty
stdout
número menor