Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String getOnePointDouble(double d) { if (d == 0) return "0.0"; try { DecimalFormat df = new DecimalFormat("######0.0"); String text = df.format(d); if (text.endsWith("0")) return text.substring(0, text.length() - 1); return text; } catch (Exception e) { return "0.0"; } } }