2024-06-24 14:21:51 +01:00
|
|
|
package cc.fascinated.bat.common;
|
|
|
|
|
2024-06-24 15:45:53 +01:00
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
2024-06-24 14:21:51 +01:00
|
|
|
/**
|
|
|
|
* @author Fascinated (fascinated7)
|
|
|
|
*/
|
|
|
|
public class NumberUtils {
|
|
|
|
/**
|
|
|
|
* Formats a number with commas.
|
2024-06-24 15:45:53 +01:00
|
|
|
* <p>
|
|
|
|
* Example: 1000 -> 1,000 | Example: 1000.5 -> 1,000.5
|
|
|
|
* </p>
|
2024-06-24 14:21:51 +01:00
|
|
|
*
|
|
|
|
* @param number the number to format
|
|
|
|
* @return the formatted number
|
|
|
|
*/
|
|
|
|
public static String formatNumberCommas(double number) {
|
2024-06-24 15:45:53 +01:00
|
|
|
NumberFormat format = NumberFormat.getNumberInstance();
|
|
|
|
format.setGroupingUsed(true);
|
|
|
|
return format.format(number);
|
2024-06-24 14:21:51 +01:00
|
|
|
}
|
|
|
|
}
|