Here you can find the source of shiftDouble(Object o, double shift, String suffix)
Parameter | Description |
---|---|
o | A string representation of a double value. |
shift | Increments or decrements the parsed value. |
suffix | A string appended to the result. |
public static String shiftDouble(Object o, double shift, String suffix)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w. j a v a 2 s . co m * @param o A string representation of a double value. * @param shift Increments or decrements the parsed value. * @param suffix A string appended to the result. */ public static String shiftDouble(Object o, double shift, String suffix) { Double d = parseDouble(o); d = d + shift; return (String.format("%.1f", d) + suffix); } /** * @param o A string representation of a double value. * @return The parsed value or 0.0 if the string couldn't be parsed. */ public static Double parseDouble(Object o) { String s = o.toString(); try { if (s.length() >= 1) { return (Double.parseDouble(s.substring(0, s.length() - 1))); } else { return (0.0); } } catch (NumberFormatException e) { return (0.0); } } }