Java BigDecimal createJsonNumber(BigDecimal d)

Here you can find the source of createJsonNumber(BigDecimal d)

Description

create Json Number

License

Apache License

Declaration

public static JsonNumber createJsonNumber(BigDecimal d) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;
import java.math.BigInteger;

import javax.json.JsonNumber;

import javax.json.JsonValue;

public class Main {
    public static JsonNumber createJsonNumber(BigDecimal d) {
        return new JsonNumber() {
            @Override/*from  ww  w  . j  a  v  a 2 s  .c o  m*/
            public boolean isIntegral() {
                return d.scale() == 0;
            }

            @Override
            public int intValue() {
                return d.intValue();
            }

            @Override
            public int intValueExact() {
                return d.intValueExact();
            }

            @Override
            public long longValue() {
                return d.longValue();
            }

            @Override
            public long longValueExact() {
                return d.longValueExact();
            }

            @Override
            public BigInteger bigIntegerValue() {
                return d.toBigInteger();
            }

            @Override
            public BigInteger bigIntegerValueExact() {
                return d.toBigIntegerExact();
            }

            @Override
            public double doubleValue() {
                return d.doubleValue();
            }

            @Override
            public BigDecimal bigDecimalValue() {
                return d;
            }

            @Override
            public JsonValue.ValueType getValueType() {
                return ValueType.NUMBER;
            }
        };
    }
}

Related

  1. bigDecimalParse(String value)
  2. bigDecimalPrint(BigDecimal value)
  3. bigDecimalProperty(ObjectNode node, String propertyName, BigDecimal propertyValue)
  4. byteOverflow(BigDecimal value)
  5. cloneBigDecimal(BigDecimal bdOriginal)
  6. createReconFileHeader(int totalCount, BigDecimal totalAmount)
  7. cuberoot(BigDecimal b)
  8. currencyFormat(BigDecimal value, char decimalDelimiter)
  9. decimalDigits(BigDecimal d)