package org.shypl.common.util;


import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Locale;

public final class NumberFormatUtils {
	
	private NumberFormatUtils() {
		
	}
	
	public static DecimalFormat decimalFormat() {
		return decimalFormat(false);
	}
	
	public static DecimalFormat decimalFormat(boolean showSign) {
		DecimalFormat formatter = (DecimalFormat)NumberFormat.getInstance(Locale.US);
		DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
		
		symbols.setGroupingSeparator(' ');
		formatter.setDecimalFormatSymbols(symbols);
		
		if (showSign) {
			formatter.setPositivePrefix("+");
		}
		
		return formatter;
	}
	
	public static DecimalFormat percentFormat() {
		DecimalFormat format = decimalFormat();
		format.setPositiveSuffix("%");
		format.setNegativeSuffix("%");
		format.setMinimumFractionDigits(2);
		format.setMaximumFractionDigits(2);
		format.setRoundingMode(RoundingMode.HALF_UP);
		return format;
	}
}

@@ -344,24 +344,26 @@
 alse);%0A%09%7D%0A%09%0A
+%09%0A
 %09public stat
@@ -409,24 +409,162 @@
 showSign) %7B%0A
+%09%09return decimalFormat(true, showSign);%0A%09%7D%0A%09%0A%09public static DecimalFormat decimalFormat(boolean useGroupingSeparator, boolean showSign) %7B%0A
 %09%09DecimalFor
@@ -704,16 +704,47 @@
 s();%0A%09%09%0A
+%09%09if (useGroupingSeparator) %7B%0A%09
 %09%09symbol
@@ -772,16 +772,23 @@
 r(' ');%0A
+%09%09%7D%0A%09%09%0A
 %09%09format

add ability not to use groupping separator