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

The following examples show how to use javax.xml.bind.DatatypeConverter#printDecimal() . 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 File: CloverDecimalConvertor.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 2
Source File: TrovitUtils.java    From OpenEstate-IO with 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 3
Source File: TrovitUtils.java    From OpenEstate-IO with 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 4
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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 5
Source File: ImmoXmlUtils.java    From OpenEstate-IO with 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 6
Source File: ImmobiliareItUtils.java    From OpenEstate-IO with Apache License 2.0 4 votes vote down vote up
public static String printLatitude(BigDecimal value) {
    if (value == null || !isValidLatitude(value))
        throw new IllegalArgumentException("Can't print latitude value!");
    else
        return DatatypeConverter.printDecimal(value);
}
 
Example 7
Source File: DaftIeUtils.java    From OpenEstate-IO with 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 8
Source File: ImmobiliareItUtils.java    From OpenEstate-IO with Apache License 2.0 4 votes vote down vote up
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 9
Source File: OpenImmoUtils.java    From OpenEstate-IO with 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 10
Source File: WisItUtils.java    From OpenEstate-IO with 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 11
Source File: WisItUtils.java    From OpenEstate-IO with 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 12
Source File: CasaItUtils.java    From OpenEstate-IO with 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 13
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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 14
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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 15
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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 16
Source File: XsValueImpl.java    From java-client-api with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return DatatypeConverter.printDecimal(value);
}
 
Example 17
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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 18
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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 19
Source File: ValueConverter.java    From java-client-api with Apache License 2.0 4 votes vote down vote up
static public String BigDecimalToString(BigDecimal value) {
  return (value == null) ? null : DatatypeConverter.printDecimal(value);
}
 
Example 20
Source File: Is24XmlUtils.java    From OpenEstate-IO with 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));
}