|
|
@@ -12,6 +12,7 @@ import android.text.Spanned;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.security.MessageDigest;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.Locale;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
@@ -260,4 +261,38 @@ public class StringUtil {
|
|
|
public static String bold(String string) {
|
|
|
return new StringBuilder().append("<b>").append(string).append("</b>").toString();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 세자리 숫자마다 콤마(,)를 추가해준다.
|
|
|
+ *
|
|
|
+ * @param s "1000"
|
|
|
+ * @return "1,000"
|
|
|
+ */
|
|
|
+ public static String toComma(String s) {
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#,##0");
|
|
|
+ return decimalFormat.format(Integer.parseInt(s));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 세자리 숫자마다 콤마(,)를 추가해준다.
|
|
|
+ *
|
|
|
+ * @param s 1000
|
|
|
+ * @return "1,000"
|
|
|
+ */
|
|
|
+ public static String toComma(int s) {
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#,##0");
|
|
|
+ return decimalFormat.format(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 세자리 숫자마다 콤마(,)를 추가해준다.
|
|
|
+ *
|
|
|
+ * @param s 1000
|
|
|
+ * @return "1,000"
|
|
|
+ */
|
|
|
+ public static String toComma(long s) {
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#,##0");
|
|
|
+ return decimalFormat.format(s);
|
|
|
+ }
|
|
|
+
|
|
|
}
|