Java Code Examples for javax.xml.bind.DatatypeConverter#printDecimal()

The following examples show how to use javax.xml.bind.DatatypeConverter#printDecimal() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String printPreisAufAnfrage(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 0 || value.compareTo(BigDecimal.TEN.pow(13)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else if (value.compareTo(BigDecimal.ZERO) == 0)
        return "0";
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 2
Source Project: OpenEstate-IO   File: TrovitUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Write a {@link BigDecimal} value into XML output
 * with a valid latitude range.
 *
 * @param value value to write
 * @return XML string
 * @throws IllegalArgumentException if a validation error occurred
 */
public static String printLatitudeValue(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print empty latitude value!");
    if (value.compareTo(new BigDecimal("-90")) < 0)
        throw new IllegalArgumentException("Can't print latitude value '" + value + "' because it is below -90!");
    if (value.compareTo(new BigDecimal("90")) > 0)
        throw new IllegalArgumentException("Can't print latitude value '" + value + "' because it is above 90!");

    value = value.setScale(10, BigDecimal.ROUND_HALF_UP);
    return DatatypeConverter.printDecimal(value);
}
 
Example 3
Source Project: OpenEstate-IO   File: TrovitUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Write a {@link BigDecimal} value into XML output for a price.
 *
 * @param value value to write
 * @return XML string
 * @throws IllegalArgumentException if a validation error occurred
 */
public static String printPriceValue(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print empty price value!");
    if (value.compareTo(BigDecimal.ZERO) < 0)
        throw new IllegalArgumentException("Can't print price value '" + value + "' because it is below 0!");
    if (value.compareTo(new BigDecimal("1000000000")) > 0)
        throw new IllegalArgumentException("Can't print price value '" + value + "' because it is above 1000000000!");

    value = value.setScale(2, BigDecimal.ROUND_HALF_UP);
    return DatatypeConverter.printDecimal(value);
}
 
Example 4
public static String printNumericToXsdDecimal(Numeric value) throws DataConversionException {
    String result = null;
    String valueType = Numeric.class.getName();
    
    try {
        BigDecimal decimal = value.getBigDecimal();
        result = DatatypeConverter.printDecimal(decimal);
    } catch(Exception e) {
        if (value != null) valueType = value.getClass().getName();
        logger.fatal("Unable to print "+valueType+" to xsd:decimal.",e);
        throw new DataConversionException("Unable to print "+valueType+" to xsd:decimal.", e);
    }
    
    return result;
}
 
Example 5
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printZahl31(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1 || value.compareTo(BigDecimal.TEN.pow(2)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else
        return DatatypeConverter.printDecimal(value.setScale(1, BigDecimal.ROUND_HALF_UP));
}
 
Example 6
Source Project: java-client-api   File: ValueConverter.java    License: Apache License 2.0 4 votes vote down vote up
static public String BigDecimalToString(BigDecimal value) {
  return (value == null) ? null : DatatypeConverter.printDecimal(value);
}
 
Example 7
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printZahl42(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1 || value.compareTo(BigDecimal.TEN.pow(2)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 8
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printZahl52(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1 || value.compareTo(BigDecimal.TEN.pow(3)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 9
Source Project: java-client-api   File: XsValueImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return DatatypeConverter.printDecimal(value);
}
 
Example 10
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printZahl72(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1 || value.compareTo(BigDecimal.TEN.pow(5)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 11
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printZahl102(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1 || value.compareTo(BigDecimal.TEN.pow(8)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 12
Source Project: OpenEstate-IO   File: Is24XmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printZahl152(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1 || value.compareTo(BigDecimal.TEN.pow(13)) >= 0)
        throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 13
Source Project: OpenEstate-IO   File: CasaItUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printDouble(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print decimal value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 14
Source Project: OpenEstate-IO   File: ImmoXmlUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printDecimal(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print double value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 15
Source Project: OpenEstate-IO   File: WisItUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printDecimal(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print decimal value!");
    else
        return DatatypeConverter.printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));
}
 
Example 16
Source Project: OpenEstate-IO   File: WisItUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printDouble(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print double value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 17
Source Project: OpenEstate-IO   File: OpenImmoUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printDecimal(BigDecimal value) {
    if (value == null)
        throw new IllegalArgumentException("Can't print double value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 18
public static String printLongitude(BigDecimal value) {
    if (value == null || !isValidLongitude(value))
        throw new IllegalArgumentException("Can't print longitude value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 19
Source Project: OpenEstate-IO   File: DaftIeUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static String printPositiveDecimal(BigDecimal value) {
    if (value == null || value.compareTo(BigDecimal.ZERO) < 1)
        throw new IllegalArgumentException("Can't print positive double value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 20
public static String printLatitude(BigDecimal value) {
    if (value == null || !isValidLatitude(value))
        throw new IllegalArgumentException("Can't print latitude value!");
    else
        return DatatypeConverter.printDecimal(value);
}