Package java.math

Examples of java.math.BigDecimal.longValue()


                // an integer number
                BigInteger v = new BigInteger(text);
                if(v.compareTo(MAX_INTEGER) <= 0 && v.compareTo(MIN_INTEGER) >= 0 ) {
                    return v.intValue();
                } else if (v.compareTo(MAX_LONG) <= 0 && v.compareTo(MIN_LONG) >= 0 ) {
                    return v.longValue();
                } else {
                    return v;
                }
            }
        } else if (type == TRUE) {
View Full Code Here


      }else if (MB.equals(unit.toUpperCase())){
        value = value.multiply(new BigDecimal(1024*1024));
      }else{
        throw new Exception(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),"Invalid unit: ")+unit);
      }
      retVal = value.longValue();
    }
    return retVal;
  }
 
  /**
 
View Full Code Here

                            // Can it be converted to a long
                            // Throws ArithmeticException on conversion failure.
                            // The following line is only available in
                            // Java5 and above:
                            //long lval = bd.longValueExact();
                            long lval = bd.longValue();

                            setValueAndType(lval);
                        } catch (ArithmeticException ex) {
                            // No, it can not be converted to long
View Full Code Here

            {
                return new Integer(value.intValue());
            }
            else if (getJavaTypeMapping().getJavaType().getName().equals(ClassNameConstants.JAVA_LANG_LONG))
            {
                return new Long(value.longValue());
            }
            else if (getJavaTypeMapping().getJavaType().getName().equals(ClassNameConstants.JAVA_LANG_BOOLEAN))
            {
                return new Boolean(value.intValue() == 1 ? true : false);
            }
View Full Code Here

            {
                return value;
            }
            else
            {
                return new Long(value.longValue());
            }
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055002","Numeric", "" + param, column, e.getMessage()),e);
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

        // fractions
        if (_fs != null && (_fs.signum() < 0 || _fs.compareTo(GDate._one) >= 0))
        {
            BigDecimal bdcarry = _fs.setScale(0, BigDecimal.ROUND_FLOOR);
            _fs = _fs.subtract(bdcarry);
            carry = bdcarry.longValue();
        }

        if (carry != 0 || _s < 0 || _s > 59 || _m < 0 || _m > 50 || _h < 0 || _h > 23)
        {
            // seconds
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

    for (int i = finalId; i >= 0; i--) {
      if (isOverflow(i, last.get(i), incs[i], sortSpecs)) {
        if (i == 0) {
          throw new RangeOverflowException(range, last, incs[i].longValue());
        }
        long rem = incrementAndGetReminder(i, last.get(i), value.longValue());
        incs[i] = new BigDecimal(rem);
        incs[i - 1] = incs[i-1].add(new BigDecimal(1));
        overflowFlag[i] = true;
      } else {
        if (i > 0) {
View Full Code Here

  }
  /** Returns the value in long. If null, zero is returned.
   */
  public long longValue() throws WrongValueException {
    final BigDecimal val = getValue();
    return val != null ? val.longValue(): 0;
  }
  /** Returns the value in short. If null, zero is returned.
   */
  public short shortValue() throws WrongValueException {
    final BigDecimal val = getValue();
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.