Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import org.w3c.dom.*;

public class Main {
    public static void addTextTagAsDouble(Node node, String tagName, double value) {
        addTextTag(node, tagName, doubleToString(value));
    }

    public static void addTextTag(Node node, String tagName, String text) {
        Document doc = node.getOwnerDocument();
        Element elem = doc.createElement(tagName);
        elem.appendChild(doc.createTextNode(text));
        node.appendChild(elem);
    }

    public static String doubleToString(double value) {
        return Double.toString(Math.floor(value * 10000.0 + 0.5) / 10000.0);
    }
}