forked from Fascinated/Bat
impl ci
This commit is contained in:
@ -1,16 +1,24 @@
|
||||
package cc.fascinated.bat.common;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
public class NumberUtils {
|
||||
/**
|
||||
* Formats a number with commas.
|
||||
* <p>
|
||||
* Example: 1000 -> 1,000 | Example: 1000.5 -> 1,000.5
|
||||
* </p>
|
||||
*
|
||||
* @param number the number to format
|
||||
* @return the formatted number
|
||||
*/
|
||||
public static String formatNumberCommas(double number) {
|
||||
return String.format("%,.0f", number);
|
||||
NumberFormat format = NumberFormat.getNumberInstance();
|
||||
format.setGroupingUsed(true);
|
||||
return format.format(number);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user