Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { /** * Format the int number as your want * * @param num * @param formatAs * @return * @throws Exception */ public static String formatNumber(int num, String formatAs) throws Exception { DecimalFormat df = new DecimalFormat(formatAs); String str2 = df.format(num); return str2; } }