Java tutorial
//package com.java2s; import android.text.TextUtils; import java.text.DecimalFormat; public class Main { public static String removeZero(double d) { DecimalFormat format = new DecimalFormat("0.#"); return format.format(d); } public static String removeZero(String s) { if (!TextUtils.isEmpty(s)) { try { double d = Double.parseDouble(s); DecimalFormat format = new DecimalFormat("0.#"); return format.format(d); } catch (Exception e) { return "0"; } } else { return "0"; } } }