Java examples for java.text:DecimalFormat
get whole dollar string
//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); } }