Android Double Format formatDoubleToTwoDecimalString(double number)

Here you can find the source of formatDoubleToTwoDecimalString(double number)

Description

format Double To Two Decimal String

Declaration

public static String formatDoubleToTwoDecimalString(double number) 

Method Source Code

//package com.java2s;

public class Main {
    public static String formatDoubleToTwoDecimalString(double number) {
        double theNumber = calculateRechargeAmountInRandsFor(number);

        return twoDecimalDoubleFormatter(theNumber);
    }/*from   w w w  .  j av a2 s.  co m*/

    public static double calculateRechargeAmountInRandsFor(double reading) {
        double amount = tariff() * reading;
        double vat = amount / 14;

        return amount + (vat * 2);
    }

    public static String twoDecimalDoubleFormatter(double number) {
        return String.format("%.2f", number);
    }

    public static double tariff() { //in the future might get it from some place server?
        return 0.838; //in rands this equal 1kw
    }
}

Related

  1. formatPriceWithTwoDecimals(Locale locale, double doubleToFormat)
  2. decimalFormat(int i, Double num)
  3. priceFormat(double price, String pattern)
  4. formatCurrency(int cents)
  5. formatBalance(Double balance, String curr)
  6. formatDouble(final double num)