List of usage examples for java.text NumberFormat format
public final String format(long number)
From source file:Main.java
public static String formatToStringWithoutDecimal(double value) { NumberFormat formatter = new DecimalFormat(FORMAT_NO_DECIMAL); return formatter.format(value); }
From source file:FormatUtils.java
public static String formatCurrency(Object value) { NumberFormat m_currencyformat = NumberFormat.getCurrencyInstance(); return m_currencyformat.format(((Number) value).doubleValue()); }
From source file:Main.java
public static String formatWithDecimal(double price) { NumberFormat formatter = new DecimalFormat(FORMAT_WITH_DECIMAL); return formatter.format(price); }
From source file:Util.java
public static String getFilesystemPathFromDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from w w w .j a v a 2 s . c o m NumberFormat format = new DecimalFormat("00"); return File.separator + format.format(calendar.get(Calendar.YEAR)) + File.separator + format.format((calendar.get(Calendar.MONTH) + 1)) + File.separator + format.format(calendar.get(Calendar.DAY_OF_MONTH)) + File.separator; }
From source file:Main.java
public static String getVersion(int version, String ver) { NumberFormat formatter = new DecimalFormat("000"); String number = ver + "." + formatter.format(version); return number.toLowerCase(); }
From source file:Main.java
public static String getFormattedValue(double value) { NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("pt", "BR")); return nf.format(value); }
From source file:Main.java
public static String getMonetaryValue(Double value) { NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.getDefault()); return numberFormat.format(value); }
From source file:Main.java
public static String convertToCurrency(float value) { DecimalFormat format = new DecimalFormat("#.##"); try {// w ww . ja v a 2s . c om value = Float.parseFloat(format.format(value)); } catch (Exception e) { e.printStackTrace(); } NumberFormat defaultFormat = NumberFormat.getCurrencyInstance(Locale.CANADA); return defaultFormat.format(value); }
From source file:Main.java
public static String toReal(Double value) { NumberFormat numberFormat = NumberFormat.getCurrencyInstance(new Locale("pt", "BR")); return numberFormat.format(value).replace("R$", "R$ "); }
From source file:Main.java
public static String toNumberFormat(long value) { NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(0);//w w w . j a v a 2s . c o m return nf.format(value); }