Example usage for javax.xml.bind DatatypeConverter printLong

List of usage examples for javax.xml.bind DatatypeConverter printLong

Introduction

In this page you can find the example usage for javax.xml.bind DatatypeConverter printLong.

Prototype

public static String printLong(long val) 

Source Link

Document

Converts A long value into a string.

Usage

From source file:Main.java

/**
 * Converts Long into XML-Tag with type xsd:long
 *///from ww w  . j  a va 2s . com
public static String getXMLLong(final long value) {
    return DatatypeConverter.printLong(value);
}

From source file:com.actian.ilabs.dataflow.stringtemplate.runner.RunStringTemplate.java

private String FormatFieldValue(ScalarInputField field) {
    ScalarTokenType type = field.getType();
    String valueString = "";

    if (type.equals(TokenTypeConstant.BOOLEAN)) {
        BooleanInputField boolField = (BooleanInputField) field;
        valueString = DatatypeConverter.printBoolean(boolField.asBoolean());
    } else if (type.equals(TokenTypeConstant.BINARY)) {
        BinaryInputField binField = (BinaryInputField) field;
        valueString = DatatypeConverter.printHexBinary(binField.asBinary());
    } else if (type.equals(TokenTypeConstant.CHAR)) {
        CharInputField charField = (CharInputField) field;
        valueString = charField.toString();
    } else if (type.equals(TokenTypeConstant.DATE)) {
        DateInputField dateField = (DateInputField) field;
        DateFormatter dateFormatter = new DateFormatter("yyyyMMdd");
        dateFormatter.setSource(dateField);
        valueString = dateFormatter.format();
    } else if (type.equals(TokenTypeConstant.DOUBLE)) {
        DoubleInputField doubleField = (DoubleInputField) field;
        valueString = DatatypeConverter.printDouble(doubleField.asDouble());
    } else if (type.equals(TokenTypeConstant.FLOAT)) {
        FloatInputField floatField = (FloatInputField) field;
        valueString = DatatypeConverter.printFloat(floatField.asFloat());
    } else if (type.equals(TokenTypeConstant.INT)) {
        IntInputField intField = (IntInputField) field;
        valueString = DatatypeConverter.printInt(intField.asInt());
    } else if (type.equals(TokenTypeConstant.LONG)) {
        LongInputField longField = (LongInputField) field;
        valueString = DatatypeConverter.printLong(longField.asLong());
    } else if (type.equals(TokenTypeConstant.NUMERIC)) {
        NumericInputField numericField = (NumericInputField) field;
        valueString = DatatypeConverter.printDecimal(numericField.asBigDecimal());
    } else if (type.equals(TokenTypeConstant.STRING)) {
        StringInputField stringField = (StringInputField) field;
        valueString = DatatypeConverter.printString(stringField.asString());
    } else if (type.equals(TokenTypeConstant.TIME)) {
        TimeInputField timeField = (TimeInputField) field;
        TimeFormatter timeFormatter = new TimeFormatter("HHmmss.SSSZ");
        timeFormatter.setSource(timeField);
        valueString = timeFormatter.format();
    } else if (type.equals(TokenTypeConstant.TIMESTAMP)) {
        TimestampInputField timestampField = (TimestampInputField) field;
        TimestampFormatter timestampFormatter = new TimestampFormatter("yyyyMMdd'T'HHmmss.SSSZ");
        timestampFormatter.setSource(timestampField);
        valueString = timestampFormatter.format();
    } else {//from ww  w  .j a va2s  .c  o  m
        valueString = "";
    }

    return valueString;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl2(Long value) {
    if (value == null || value <= 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 2)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 2 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl2Including0(Long value) {
    if (value == null || value < 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 2)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 2 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl3(Long value) {
    if (value == null || value <= 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 3)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 3 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl3Including0(Long value) {
    if (value == null || value < 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 3)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 3 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl4(Long value) {
    if (value == null || value <= 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 4)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 4 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl5(Long value) {
    if (value == null || value <= 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 5)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 5 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl8(Long value) {
    if (value == null || value <= 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 8)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 8 digits.");
    return val;
}

From source file:org.openestate.io.is24_xml.Is24XmlUtils.java

public static String printZahl10(Long value) {
    if (value == null || value <= 0)
        throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
    String val = DatatypeConverter.printLong(value);
    if (val.length() > 10)
        throw new IllegalArgumentException(
                "Can't print integer value '" + value + "'! The value exceeds maximal length of 10 digits.");
    return val;
}