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

StringformatIndexValuePairs(List indicies, List values, String valueSeparator, String rangeSeparator)
format Index Value Pairs
DecimalFormat formatter = new DecimalFormat("#,##0.#");
StringBuilder builder = new StringBuilder();
int startRange = 0;
int previousIndex = 0;
double rangeValue = 0;
for (int i = 0; i < indicies.size(); i++) {
    int index = indicies.get(i);
    double value = values.get(i);
...
StringformatInt(double value)
Formats a specified numeric value as int.
return INT_FORMAT.format(value);
StringformatIntoCurr(double num, int digits)
Use this method like this:
String formatted = Util.formatIntoCurr(123456789.123, 2);
formatted ==> "123,456,789.12"
return formatIntoCurr("" + num, digits);
StringformatIntRate(double rateInt)
format Int Rate
try {
    NumberFormat nf = new DecimalFormat("0.00");
    String moneyValue = nf.format(rateInt * 100);
    return moneyValue + "%";
} catch (Exception ex) {
    return "";
StringformatKnots(double v)
format Knots
return new DecimalFormat(FORMAT_SHORT).format(toKnots(v)) + " " + UNIT_KNOTS;
StringformatManeyPattern(String pattern, Double amount)
format Maney Pattern
NumberFormat nf = new DecimalFormat(pattern);
return nf.format(amount);
StringformatMetricsDecimal(double value)
format Metrics Decimal
if (value == -1 || Double.isNaN(value) || Double.isInfinite(value)) {
    return NO_METRICS_LABEL;
} else {
    return getDecimalFormatter().format(value);
StringformatNoGrouping(double value)
format No Grouping
NumberFormat groupedFormat = NumberFormat.getNumberInstance();
groupedFormat.setGroupingUsed(false);
return groupedFormat.format(value);
StringformatNormalDouble(double value)
format Normal Double
String formattedDouble = formatDouble(value, "0.000");
return formattedDouble;
StringformatNum(double d)
format Num
DecimalFormat df = new DecimalFormat("####,##0.00");
String result = df.format(d);
if (".00".equals(result)) {
    result = "0" + result;
return result;