package info.puzz.graphanything.models.format;

import info.puzz.graphanything.utils.StringUtils;

/**
 * Created by puzz on 11/10/16.
 */

public class DoubleFormatter implements FormatterParser {
    @Override
    public Double parse(String str) throws FormatException {
        if (StringUtils.isEmpty(str)) {
            return null;
        }
        try {
            return Double.parseDouble(str.trim());
        } catch (NumberFormatException e) {
            throw new FormatException("Invalid number:" + str);
        }
    }

    @Override
    public String format(Double value) {
        if (value == null) {
            return "";
        }
        return String.format("%.2", value);
    }
}

@@ -681,16 +681,17 @@
 mat(%22%25.2
+f
 %22, value
@@ -698,11 +698,127 @@
 );%0A    %7D
+%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(new DoubleFormatter().format(2.3D));%0A    %7D
 %0A%7D%0A

Format fix