Android Double Format formatToTwoDecimalPlaces(String decimal)

Here you can find the source of formatToTwoDecimalPlaces(String decimal)

Description

format To Two Decimal Places

Declaration

public static final String formatToTwoDecimalPlaces(String decimal) 

Method Source Code

//package com.java2s;
import java.text.DecimalFormat;
import java.text.ParseException;

public class Main {
    public static final DecimalFormat format = new DecimalFormat("0.00");

    public static final String formatToTwoDecimalPlaces(String decimal) {
        try {//from w ww .  j a  va2  s .c o m
            return format.format(format.parse(decimal));
        } catch (ParseException e) {
            return decimal;
        }
    }
}

Related

  1. formatPriceWithTwoDecimals(Locale locale, double doubleToFormat)
  2. decimalFormat(int i, Double num)
  3. priceFormat(double price, String pattern)
  4. formatCurrency(int cents)