Is there a way to use DecimalFormat (or some other standard formatter) to format numbers like this:
1,000,000 => 1.00M
1,234,567 =>
For someone looking out there to convert a given digit in human readable form.
public static String getHumanReadablePriceFromNumber(long number){
if(number >= 1000000000){
return String.format("%.2fB", number/ 1000000000.0);
}
if(number >= 1000000){
return String.format("%.2fM", number/ 1000000.0);
}
if(number >= 100000){
return String.format("%.2fL", number/ 100000.0);
}
if(number >=1000){
return String.format("%.2fK", number/ 1000.0);
}
return String.valueOf(number);
}