Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String formatPrice(String price) { String tempPrice = "0"; if (null != price && !"".equals(price)) { double d = Double.parseDouble(price); if (d != 0) { DecimalFormat df = new DecimalFormat("##0.00"); tempPrice = df.format(Double.parseDouble(price)); } } return tempPrice; } }