Package java.math

Examples of java.math.BigDecimal.longValue()


            excerpt.finish();
        }
        for (int i = 0; i < objects; i++) {
            assertTrue(excerpt.index(i));
            BigDecimal bd = (BigDecimal) excerpt.readObject();
            assertEquals(i % 1000, bd.longValue());
            excerpt.finish();
        }
//        System.out.println("waiting");
//        Thread.sleep(20000);
//        System.out.println("waited");
View Full Code Here


                BigDecimal intlit = new BigDecimal
                    (node.text.endsWith("l") || node.text.endsWith("L")
                        ? node.text.substring(0, node.text.length() - 1)
                        : node.text).
                    multiply(new BigDecimal(negative(node)));
                return factory.newLiteral(new Long(intlit.longValue()),
                    Literal.TYPE_NUMBER);

            case JJTDECIMALLITERAL:
                BigDecimal declit = new BigDecimal
                    (node.text.endsWith("d") || node.text.endsWith("D") ||
View Full Code Here

            Class<?> parameterType = setter.getParameterTypes()[0];
            if (columnValue instanceof BigDecimal && (parameterType == long.class || parameterType == Long.class)) {
                columnValue = ((BigDecimal) columnValue).longValue();
            } else if (columnValue instanceof BigDecimal && parameterType == boolean.class) {
                BigDecimal bd = (BigDecimal) columnValue;
                if (bd.longValue() == 0) {
                    columnValue = false;
                } else if (bd.longValue() == 1) {
                    columnValue = true;
                }
            } else if (columnValue instanceof Clob && parameterType == String.class) {
View Full Code Here

                columnValue = ((BigDecimal) columnValue).longValue();
            } else if (columnValue instanceof BigDecimal && parameterType == boolean.class) {
                BigDecimal bd = (BigDecimal) columnValue;
                if (bd.longValue() == 0) {
                    columnValue = false;
                } else if (bd.longValue() == 1) {
                    columnValue = true;
                }
            } else if (columnValue instanceof Clob && parameterType == String.class) {
                Clob clob = (Clob) columnValue;
                columnValue = IOUtils.toString(clob.getAsciiStream());
View Full Code Here

        case TYPE_FLOAT:
            resultObj = Float.valueOf(resultValue.floatValue());
            break;
        case TYPE_LONG:
            resultValue = resultValue.setScale(0, roundingMode);
            resultObj = Long.valueOf(resultValue.longValue());
            break;
        case TYPE_INTEGER:
            resultValue = resultValue.setScale(0, roundingMode);
            resultObj = Integer.valueOf(resultValue.intValue());
            break;
View Full Code Here

    // this matches DB2 UDB behaviour

    if (   (localValue.compareTo(SQLDecimal.MINLONG_MINUS_ONE) == 1)
      && (localValue.compareTo(SQLDecimal.MAXLONG_PLUS_ONE) == -1)) {

      return localValue.longValue();
    }

    throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "BIGINT");
  }
View Full Code Here

       ** This loses the fractional part, but it probably doesn't
       ** matter for numbers that are big enough to overflow a double -
       ** it's probably rare for numbers this big to be different only in
       ** their fractional parts.
       */
      longVal = localValue.longValue();
    }
    else
    {
      longVal = (long) doubleVal;
      if (longVal != doubleVal)
View Full Code Here

        }
        if ((dhlShipmentDetailCode.equals("G") && shippableWeight.compareTo(new BigDecimal("999")) > 0) || (shippableWeight.compareTo(new BigDecimal("150")) > 0)) {
            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                    "FacilityShipmentDhlShippableWeightExceed", locale));
        }
        String weight = (Integer.valueOf((int) shippableWeight.longValue())).toString();

        // create AccessRequest XML doc using FreeMarker template
        String templateName = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "rateEstimateTemplate", resource, "shipment.dhl.template.rate.estimate");
        if ((templateName == null) || (templateName.trim().length() == 0)) {
            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
View Full Code Here

    public void testGetLongOnDecimal() throws RepositoryException {
        BigDecimal bd1 = new BigDecimal(Long.MAX_VALUE);
        BigDecimal bd2 = new BigDecimal(Double.MIN_VALUE);

        assertEquals(bd1.longValue(), factory.create(bd1).getLong());
        assertEquals(bd2.longValue(), factory.create(bd2).getLong());
    }

    //------------------------------------------------------------< BOOLEAN >---
    /**
     * QValueImpl has a final static constant for the TRUE and the FALSE boolean
View Full Code Here

    final Number date1 = typeRegistry.convertToNumber(parameters.getType(0), parameters.getValue(0));
    final Number date2 = typeRegistry.convertToNumber(parameters.getType(1), parameters.getValue(1));

    final BigDecimal dn1 = NumberUtil.performIntRounding(NumberUtil.getAsBigDecimal(date1));
    final BigDecimal dn2 = NumberUtil.performIntRounding(NumberUtil.getAsBigDecimal(date2));
    return dn2.longValue() - dn1.longValue();
  }

  protected long computeDateDifference(final String formatCode,
                                       final GregorianCalendar min,
                                       final GregorianCalendar max,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.