get whole dollar string - Java java.text

Java examples for java.text:DecimalFormat

Description

get whole dollar string

Demo Code


//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    public static void main(String[] argv) throws Exception {
        double fen = 2.45678;
        System.out.println(getYuan(fen));
    }/*  ww w .  jav a  2s . co m*/

    public static String getYuan(double fen) {
        double yuan = fen / 100.00;
        DecimalFormat dft = new DecimalFormat("0.00");
        return dft.format(yuan);
    }
}

Related Tutorials