Here you can find the source of getRoundPercent(double f)
public static String getRoundPercent(double f)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String getRoundPercent(double f) { DecimalFormat df = new DecimalFormat("#####.00"); return df.format(f); }//from w w w . j a v a 2 s. c om public static int getRoundPercent(float f) { double r = f * 100; String round = String.valueOf(r); if (round.indexOf(".") > 0) { round = round.substring(0, round.indexOf(".")); int intValue = Integer.parseInt(round); if (r - intValue >= 0.5) intValue += 1; round = String.valueOf(intValue); } return Integer.parseInt(round); } }