Java Utililty Methods Fraction Format

List of utility methods to do Fraction Format

Description

The list of methods to do Fraction Format are organized into topic(s).

Method

StringformatAnotherString(double valor)
format Another String
DecimalFormat format = new DecimalFormat("#,##0.00");
return format.format(valor);
StringformataNum(double numero)
formata Num
return formataNum(numero, "0.##");
doubleformatAvgTime(double avg)
format Avg Time
String avgTime;
if (avg < 0.01) {
    avgTime = new DecimalFormat(",000").format(avg);
} else if (avg < 0.1) {
    avgTime = new DecimalFormat(",00").format(avg);
} else {
    avgTime = new DecimalFormat(".").format(avg);
return Double.parseDouble(avgTime);
StringformatBet(Double betOdd, int formatterDigits)
Format bet.
configureFormatter(formatterDigits);
return DECIMAL_FORMATTER.format(betOdd);
StringformatBetHandicap(Double handicap)
Format bet handicap.
configureFormatterHandicap();
String result;
String handicapStr = HANDICAP_FORMATTER.format(handicap);
if (handicap > 0) {
    result = new StringBuffer("+").append(handicapStr).toString();
} else if (handicap < 0) {
    result = handicapStr;
} else {
...
StringformatBytes(final double bytes)
Formats the given number of bytes into an easily readable format
String scaledY;
if (bytes < 10000) {
    scaledY = BYTES_FORMAT.format((long) bytes) + " B";
} else if (bytes <= 500 * 1024) {
    scaledY = BYTES_FORMAT.format(bytes / 1024) + " KB";
} else {
    scaledY = MB_FORMAT.format(((float) bytes / (1024 * 1024))) + " MB";
return scaledY;
StringformatCoordinates(double lat, double lon)
Return text representation of coordinates.
String r = "";
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
symbols.setGroupingSeparator(' ');
DecimalFormat df = new DecimalFormat("#.00000", symbols);
r = "(" + df.format(lat) + ", " + df.format(lon) + ")";
return r;
StringformatCPUUtilization(double d)
format CPU Utilization
DecimalFormat decimalFormat = new DecimalFormat("0.00");
if (d < 0) {
    return "NA";
} else {
    return decimalFormat.format(d * 100).replace(",", ".");
StringformatD(double d)
Format as double
return nf.format(d);
StringformatData(double aAmount)
Format the amount of data in bytes to a nice readable string
DecimalFormat df = new DecimalFormat("#,###,###.##");
String type = "";
double niceDataDown = 0;
double dataDown = aAmount;
if (dataDown < 1024) {
    niceDataDown = dataDown;
    type = " bytes";
} else if ((dataDown / 1024) < 1024) {
...