Here you can find the source of formatDoube(double val)
Parameter | Description |
---|---|
val | a parameter |
public static String formatDoube(double val)
//package com.java2s; /*/* ww w . j a v a2s . c om*/ * @(#)ConversionUtil.java * * Copyright by ObjectFrontier, Inc., * 12225 Broadleaf Lane, Alpharetta, GA 30005, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of ObjectFrontier, Inc. You shall not disclose such Confidential * Information and shall use it only in accordance with the terms of * the license agreement you entered into with ObjectFrontier. */ import java.text.DecimalFormat; public class Main { protected static DecimalFormat doubleStringFormat = new DecimalFormat("0.00"); /** * This method is used to format the value to 2 decimal places * if val is 800.0 then this method will return 800.00 * if val is 800.136 then this method will return 800.14 * @param val * @return */ public static String formatDoube(double val) { return doubleStringFormat.format(String.valueOf(val)); } }