Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Locale; public class Main { public static String padString(String str) { if (str == null || str.isEmpty()) { return "0"; } else if (str.equals(".")) { return "0."; } else { try { return String.format(Locale.ENGLISH, "%.4f", Double.parseDouble(str)); } catch (Exception e) { return null; } } } }