Java Currency Format toCurrencyAmountStr(Long microAmount)

Here you can find the source of toCurrencyAmountStr(Long microAmount)

Description

Converts micro amount to currency amount.

License

Open Source License

Parameter

Parameter Description
microAmount the micro amount value

Declaration

public static String toCurrencyAmountStr(Long microAmount) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.text.DecimalFormat;

public class Main {
    private static final long MICRO_MULTIPLIER = 1000000;
    private static final DecimalFormat df = new DecimalFormat("0.##");

    /**/*w w w.  j  a v  a  2 s  .  c om*/
     * Converts micro amount to currency amount.
     *
     * @param microAmount the micro amount value
     */
    public static String toCurrencyAmountStr(Long microAmount) {
        double normalAmount = (double) microAmount / MICRO_MULTIPLIER;
        return df.format(normalAmount);
    }
}

Related

  1. getCurrencyFormatter()
  2. parseCurrency(String currency)
  3. removeTrailingZeroes(BigDecimal value, boolean isCurrency)
  4. roundToCurrencyString(double amount)
  5. toCurrency(Object objectValue)
  6. toCurrencyFormat(String input)
  7. toCurrencyFormat(String pattern, double value)
  8. toCurrencyWord(Double doubleValue, Locale locale)