1 48 49 package org.jpublish.util; 50 51 import java.text.NumberFormat ; 52 53 59 60 public class NumberUtilities { 61 62 private static final NumberUtilities numberUtilities = new NumberUtilities(); 63 64 69 70 public static NumberUtilities getInstance() { 71 return numberUtilities; 72 } 73 74 80 81 public String format(double d, int places) { 82 NumberFormat nf = NumberFormat.getInstance(); 83 nf.setMinimumFractionDigits(places); 84 nf.setMaximumFractionDigits(places); 85 return nf.format(d); 86 } 87 88 94 95 public String format(Double d, int places) { 96 return format(d.doubleValue(), places); 97 } 98 99 105 106 public String format(String d, int places) { 107 return format(Double.parseDouble(d), places); 108 } 109 110 } 111 | Popular Tags |