Beispiel #1
0
  @Override
  public void onClick(View v) {
    try {
      int height_ft = Integer.parseInt(eheight_ft.getText().toString());
      int height_inch = Integer.parseInt(eheight_inch.getText().toString());
      int height = height_ft * 12 + height_inch;
      int weight = Integer.parseInt(eweight.getText().toString());
      float pounds = (float) (weight * 2.20462);
      float bmi = (pounds / (height * height)) * 703;
      dg = new BigDecimal(bmi);
      bmi1 = dg.setScale(2, BigDecimal.ROUND_FLOOR);

      if (bmi1.floatValue() < 18.5) {
        ((TextView) findViewById(R.id.textView))
            .setText("Your Bmi:" + bmi1.floatValue() + "\nYour Underweight");
      }
      if (bmi1.floatValue() >= 18.5 && bmi1.floatValue() <= 24.9) {
        ((TextView) findViewById(R.id.textView))
            .setText("Your Bmi:" + bmi1.floatValue() + "\nYour Weight Is Normal");
      }
      if (bmi1.floatValue() >= 25 && bmi1.floatValue() <= 29.9) {
        ((TextView) findViewById(R.id.textView))
            .setText("Your Bmi:" + bmi1.floatValue() + "\nYour Overweight");
      }
      if (bmi1.floatValue() >= 30) {
        ((TextView) findViewById(R.id.textView))
            .setText("Your Bmi:" + bmi1.floatValue() + "\nYour Obese " + "\n Stop eating fat ass");
      }

    } catch (NumberFormatException e) {
      eheight_ft.setText("");
      eweight.setText("");
      Toast.makeText(getApplicationContext(), "Enter proper values", Toast.LENGTH_LONG).show();
    }
  }
  public void addPoint() {
    double x = 0;
    double y = 0;
    Cursor cursor = null;

    if (!appState.isDBOpen()) {
      appState.getDB();
    }

    if (!"".equals(appState.userID)) {
      cursor = appState.database.getshuimian(appState.userID);
      if (cursor != null && cursor.getCount() > 0) {
        cursor.moveToFirst();
        starttime = new String[cursor.getCount()];
        endtime = new String[cursor.getCount()];
        duration = new String[cursor.getCount()];
        recfile = new String[cursor.getCount()];
        while (!cursor.isAfterLast()) {
          x++;
          String s = cursor.getString(6); // 取原始duration (ext1字段)
          String h = s.substring(0, s.indexOf("h"));
          String m = s.substring(s.indexOf(h) + 2, s.indexOf("m"));
          y = Integer.valueOf(h) + Integer.valueOf(m) / 60.0;
          BigDecimal bd = new BigDecimal(y);
          bd = bd.setScale(1, BigDecimal.ROUND_HALF_UP);
          //					y = bd.floatValue();
          mCurrentSeries.add(x, bd.floatValue());

          duration[(int) (x - 1)] = String.valueOf(bd.floatValue());
          starttime[(int) (x - 1)] = cursor.getString(3);
          endtime[(int) (x - 1)] = cursor.getString(4);
          if (!"".equals(cursor.getString(2))) {
            recfile[(int) (x - 1)] = cursor.getString(1) + cursor.getString(2);
          } else {
            recfile[(int) (x - 1)] = "";
          }

          cursor.moveToNext();
        }
        cursor.close();
      }
    }

    if (mChartView != null) {
      mChartView.repaint(); // 重画图表
    }
    // 生成图片保存,注释掉下面的代码不影响图表的生成.
    // -->start
    //        Bitmap bitmap = mChartView.toBitmap();
    //        try {
    //          File file = new File(Environment.getExternalStorageDirectory(), "test" + index++ +
    // ".png");
    //          FileOutputStream output = new FileOutputStream(file);
    //          bitmap.compress(CompressFormat.PNG, 100, output);
    //        } catch (Exception e) {
    //          e.printStackTrace();
    //        }
    // -->end
  }
  @Override
  protected boolean checkCommandHook() {
    int auktionsId;
    try {
      auktionsId = Integer.parseInt(commandArgs[1]);
    } catch (NumberFormatException e) {
      return false;
    }

    BigDecimal amount = null;
    try {
      DecimalFormat df = new DecimalFormat();
      df.setParseBigDecimal(true);
      amount = (BigDecimal) df.parse(commandArgs[2]);
    } catch (ParseException e) {
      return false;
    }

    if (amount.floatValue() > 0 && auktionsId > 0) {
      return true;
    } else {
      Output.println("no negative numbers");
      return false;
    }
  }
Beispiel #4
0
  public static ArrayList<BigDecimal> factors(BigDecimal query) {
    if (query.equals(new BigDecimal("0"))) {
      return null;
    }

    ArrayList<BigDecimal> factors = new ArrayList<BigDecimal>();

    BigDecimal sqrt = sqrt(query);

    if (sqrt.remainder(new BigDecimal("1")).equals(new BigDecimal("0"))) {
      factors.add(sqrt);
    }

    for (float i = 1; i < sqrt.floatValue(); i++) {
      // simplifying assumption
      if (factors.size() > 2) {
        break;
      }

      String m = Float.toString(i);
      BigDecimal otherFactor = query.divide(new BigDecimal(m), MathContext.DECIMAL128);

      if (query
              .divide(new BigDecimal(m), MathContext.DECIMAL128)
              .remainder(new BigDecimal(1))
              .floatValue()
          == 0) {
        factors.add(new BigDecimal(m));
        factors.add(query.divide(new BigDecimal(m)));
      }
    }

    return factors;
  }
Beispiel #5
0
 public float getFloat(String key) {
   Object temp = get(key);
   float rv = (float) 0.00;
   if (temp == null) ;
   else if (temp instanceof Long) {
     Long l = (Long) temp;
     long v = l.longValue();
     rv = (float) v;
   } else if (temp instanceof BigDecimal) {
     BigDecimal bd = (BigDecimal) temp;
     rv = bd.floatValue();
   } else if (temp instanceof Double) {
     Double d = (Double) temp;
     double v = d.doubleValue();
     rv = (float) v;
   } else if (temp instanceof Float) {
     Float f = (Float) temp;
     rv = f.floatValue();
   } else if (temp instanceof Short) {
     Short s = (Short) temp;
     short v = s.shortValue();
     rv = (float) v;
   } else if (temp instanceof Byte) {
     Byte b = (Byte) temp;
     byte v = b.byteValue();
     rv = (float) v;
   } else if (temp instanceof Integer) {
     Integer i = (Integer) temp;
     int v = i.intValue();
     rv = (float) v;
   }
   return rv;
 }
 /**
  * Calculate of Nyquist velocity
  *
  * @param prf PRF in Hertz
  * @param wave wavelength in 1/100 of centimeters
  * @return float value of Nyquist velocity in m/sec with precision of two decimal
  */
 static float calcNyquist(int prf, int wave) {
   double tmp = (prf * wave * 0.01) * 0.25;
   tmp = tmp * 0.01; // Make it m/sec
   BigDecimal bd = new BigDecimal(tmp);
   BigDecimal result = bd.setScale(2, RoundingMode.HALF_DOWN);
   return result.floatValue();
 }
 // If the Decision Table model was pre-5.4 Numeric data-types were always stored as
 // BigDecimals. This function attempts to set the correct DTCellValue property based
 // on the *true* data type.
 private void convertDTCellValueFromNumeric(DataType.DataTypes dataType, DTCellValue52 dcv) {
   // Generic type NUMERIC was always stored as a BigDecimal
   final BigDecimal value = (BigDecimal) dcv.getNumericValue();
   switch (dataType) {
     case NUMERIC_BIGDECIMAL:
       dcv.setNumericValue(value == null ? null : value);
       break;
     case NUMERIC_BIGINTEGER:
       dcv.setNumericValue(value == null ? null : value.toBigInteger());
       break;
     case NUMERIC_BYTE:
       dcv.setNumericValue(value == null ? null : value.byteValue());
       break;
     case NUMERIC_DOUBLE:
       dcv.setNumericValue(value == null ? null : value.doubleValue());
       break;
     case NUMERIC_FLOAT:
       dcv.setNumericValue(value == null ? null : value.floatValue());
       break;
     case NUMERIC_INTEGER:
       dcv.setNumericValue(value == null ? null : value.intValue());
       break;
     case NUMERIC_LONG:
       dcv.setNumericValue(value == null ? null : value.longValue());
       break;
     case NUMERIC_SHORT:
       dcv.setNumericValue(value == null ? null : value.shortValue());
       break;
   }
 }
 /**
  * Convert 4 bytes binary angle to float
  *
  * @param ang four bytes binary angle
  * @return float value of angle with precision of two decimal in degrees
  */
 static float calcAngle(int ang) {
   final double maxval = 4294967296.0;
   double temp = (ang / maxval) * 360.0;
   BigDecimal bd = new BigDecimal(temp);
   BigDecimal result = bd.setScale(3, RoundingMode.HALF_DOWN);
   return result.floatValue();
 }
 /**
  * Calculate data values from raw ingest data
  *
  * @param recHdr java.util.Map object with values for calculation
  * @param dty type of data ( "Total_Power", "Reflectivity", "Velocity", "Width",
  *     "Differential_Reflectivity")
  * @param data 1-byte input value
  * @return float value with precision of two decimal
  */
 static float calcData(Map<String, Number> recHdr, short dty, byte data) {
   short[] coef = {1, 2, 3, 4}; // MultiPRF modes
   short multiprf = recHdr.get("multiprf").shortValue();
   float vNyq = recHdr.get("vNyq").floatValue();
   double temp = -999.99;
   switch (dty) {
     default: // dty=1,2 -total_power, reflectivity (dBZ)
       if (data != 0) {
         temp = (((int) data & 0xFF) - 64) * 0.5;
       }
       break;
     case 3: // dty=3 - mean velocity (m/sec)
       if (data != 0) {
         temp = ((((int) data & 0xFF) - 128) / 127.0) * vNyq * coef[multiprf];
       }
       break;
     case 4: // dty=4 - spectrum width (m/sec)
       if (data != 0) {
         double v = ((((int) data & 0xFF) - 128) / 127.0) * vNyq * coef[multiprf];
         temp = (((int) data & 0xFF) / 256.0) * v;
       }
       break;
     case 5: // dty=5 - differential reflectivity (dB)
       if (data != 0) {
         temp = ((((int) data & 0xFF) - 128) / 16.0);
       }
       break;
   }
   BigDecimal bd = new BigDecimal(temp);
   BigDecimal result = bd.setScale(2, RoundingMode.HALF_DOWN);
   return result.floatValue();
 }
Beispiel #10
0
 public float getFloat() throws SQLException {
   truncated_ = 0;
   outOfBounds_ = false;
   if (scale_ > 0) // @C0A
   return bigDecimalValue_.floatValue(); // @A0A
   else // @C0A
   return (float) value_; // @A0D @C0A
 }
 /**
  * Used by tests of generateAccountDistributionForProration and related methods to make
  * comparisons between the percentages given by the resulting distributed accounts and the
  * percentages that we think should be correct for those lines.
  *
  * @param distributedAccounts A List of the PurApAccountingLines that result from the distribution
  *     to be tested.
  * @param correctPercents A List of percents we think should be correct, in BigDecimal format
  */
 private void comparePercentages(
     List<PurApAccountingLine> distributedAccounts, List<BigDecimal> correctPercents) {
   for (int i = 0; i < distributedAccounts.size(); i++) {
     PurApAccountingLine line = distributedAccounts.get(i);
     BigDecimal percent = line.getAccountLinePercent();
     assertTrue(percent.floatValue() == correctPercents.get(i).floatValue());
   }
 }
Beispiel #12
0
 private String valueOf(float current) {
   if (precision >= 1) {
     // dealing with float rounding errors
     BigDecimal bd = new BigDecimal(String.valueOf(current));
     bd = bd.setScale(precision, BigDecimal.ROUND_HALF_UP);
     return String.valueOf(bd.floatValue());
   } else return String.valueOf((int) current);
 }
 public static void main(String[] args) {
   BigDecimal a = new BigDecimal(12.88);
   float b = a.floatValue();
   System.out.println(b == 12.88f); // b=12;
   String s1 = "he";
   String s2 = "o";
   String str = s1 + "ll" + s2;
   System.out.println(str);
 }
Beispiel #14
0
  public static float round(float val, float precision) {
    BigDecimal bval = new BigDecimal(val);
    BigDecimal bp = new BigDecimal(1 / precision);
    BigDecimal bip = new BigDecimal((int) val);
    BigDecimal bdp = bval.subtract(bip);

    BigDecimal bnval = bdp.multiply(bp);
    BigDecimal bnip = new BigDecimal((int) bnval.floatValue());
    BigDecimal bndp = bnval.subtract(bnip);

    BigDecimal one = new BigDecimal(1);
    BigDecimal compare = new BigDecimal(.5f);
    BigDecimal diff = one.subtract(bndp);
    if (diff.compareTo(compare) == -1) bnip = bnip.add(one);

    BigDecimal res = bip.add(bnip.divide(bp));
    return res.floatValue();
  }
Beispiel #15
0
  private void selectNecessarios(JTablePad tab) {

    BigDecimal qtdaprod = null;

    for (int i = 0; i < tab.getNumLinhas(); i++) {
      qtdaprod = (BigDecimal) tab.getValor(i, DETALHAMENTO.QTDAPROD.ordinal());
      tab.setValor(new Boolean(qtdaprod.floatValue() > 0), i, 0);
    }
  }
 /**
  * Calculate radial elevation of each ray
  *
  * @param angle two bytes binary angle
  * @return float value of elevation in degrees with precision of two decimal
  */
 static float calcElev(short angle) {
   final double maxval = 65536.0;
   double ang = (double) angle;
   if (angle < 0) ang = (~angle) + 1;
   double temp = (ang / maxval) * 360.0;
   BigDecimal bd = new BigDecimal(temp);
   BigDecimal result = bd.setScale(2, RoundingMode.HALF_DOWN);
   return result.floatValue();
 }
Beispiel #17
0
  @SuppressWarnings("unchecked")
  public static <T> T cast(Object obj, Class<T> clazz) throws Exception {
    if (obj == null) {
      return null;
    }
    TypeToken<T> type = TypeToken.of(clazz).wrap();
    TypeToken<?> objType = TypeToken.of(obj.getClass()).wrap();

    if (type.isAssignableFrom(objType)) {
      return (T) obj;
    }
    if (TypeToken.of(List.class).isAssignableFrom(type) && objType.isArray()) {
      List<Object> list = Arrays.asList((Object[]) obj);
      return (T) list;
    }
    if (type.isArray() && TypeToken.of(List.class).isAssignableFrom(objType)) {
      List<?> list = (List<?>) obj;
      TypeToken<?> componentType = type.getComponentType();
      Class<?> rawType;
      if (componentType == null) {
        rawType = Object.class;
      } else {
        rawType = componentType.getRawType();
      }
      Object[] array = (Object[]) Array.newInstance(rawType, list.size());
      return (T) list.toArray(array);
    }
    if (clazz.isEnum()) {
      return (T) Enum.valueOf((Class<? extends Enum>) clazz, obj.toString());
    }
    if (TypeToken.of(String.class).isAssignableFrom(type)) {
      return (T) obj.toString();
    }
    if (TypeToken.of(Number.class).isAssignableFrom(type)) {
      BigDecimal num = new BigDecimal(obj.toString());
      if (TypeToken.of(Integer.class).isAssignableFrom(type)) {
        return (T) Integer.valueOf(num.intValue());
      }
      if (TypeToken.of(Long.class).isAssignableFrom(type)) {
        return (T) Long.valueOf(num.longValue());
      }
      if (TypeToken.of(Short.class).isAssignableFrom(type)) {
        return (T) Short.valueOf(num.shortValue());
      }
      if (TypeToken.of(Byte.class).isAssignableFrom(type)) {
        return (T) Byte.valueOf(num.byteValue());
      }
      if (TypeToken.of(Float.class).isAssignableFrom(type)) {
        return (T) Float.valueOf(num.floatValue());
      }
      if (TypeToken.of(Double.class).isAssignableFrom(type)) {
        return (T) Double.valueOf(num.doubleValue());
      }
    }
    return null;
  }
  /** @exception StandardException thrown on failure to convert */
  public float getFloat() throws StandardException {
    BigDecimal localValue = getBigDecimal();
    if (localValue == null) return (float) 0;

    // If the BigDecimal is out of range for the float
    // then positive or negative infinity is returned.
    float value = NumberDataType.normalizeREAL(localValue.floatValue());

    return value;
  }
 private float TaxCalc() {
   float InitialTax;
   if (isImported) {
     InitialTax = LocalTax.calc(this) + ImportedTax.calc(this);
   } else {
     InitialTax = LocalTax.calc(this);
   }
   float Tax_f = (float) (Math.ceil(InitialTax * 20.0) / 20.0);
   BigDecimal Tax_b = new BigDecimal(Tax_f);
   return Tax_b.floatValue();
 }
Beispiel #20
0
 private void send(String address, float amount) {
   DialogSend dialog = new DialogSend();
   dialog.setLocationRelativeTo(frmWow);
   BigDecimal valueInBTC =
       new BigDecimal(coreWallet.getBalance()).divide(new BigDecimal(Utils.COIN));
   dialog.setMaximum(valueInBTC.floatValue());
   dialog.setNetworkParameters(coreWallet.getNetworkParameters());
   if (address != null) {
     dialog.setAddress(address);
     dialog.setAmount(amount);
   }
   while (dialog.showDialog()) {
     System.out.println(
         "SEND: " + dialog.getAddress() + " " + dialog.getAmount() + " " + dialog.isFeeUsed());
     try {
       if (coreWallet.isEncrypted()) {
         DialogPassword d = new DialogPassword();
         d.setLocationRelativeTo(frmWow);
         if (d.showDialog()) {
           try {
             if (coreWallet.checkPassword(new String(d.getPassword()))) {
               coreWallet.sendCoins(
                   dialog.getAddress(), dialog.getAmount(), new String(d.getPassword()));
             } else {
               JOptionPane.showMessageDialog(
                   frmWow,
                   "Not correct password provided!",
                   "Information",
                   JOptionPane.INFORMATION_MESSAGE);
               break;
             }
           } catch (KeyCrypterException e) {
             JOptionPane.showMessageDialog(
                 frmWow, "Wallet dencryption failed!", "Error", JOptionPane.ERROR_MESSAGE);
             break;
           }
         }
         // coreWallet.sendCoins(dialog.getAddress(), dialog.getAmount());
       } else coreWallet.sendCoins(dialog.getAddress(), dialog.getAmount());
       break;
     } catch (InsufficientMoneyException e) {
       JOptionPane.showMessageDialog(
           frmWow, "Insufficient coins!", "Warning", JOptionPane.WARNING_MESSAGE);
       break;
     } catch (KeyCrypterException e) {
       JOptionPane.showMessageDialog(frmWow, e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
       break;
     }
   }
 }
Beispiel #21
0
  private void geraOPS() {

    StringBuffer sql = new StringBuffer();
    Vector<Integer> ops = new Vector<Integer>();
    BigDecimal qtdsugerida = null;
    DLLoading loading = new DLLoading();

    try {
      for (int i = 0; i < tabDet.getNumLinhas(); i++) {
        loading.start();
        qtdsugerida = (BigDecimal) (tabDet.getValor(i, DETALHAMENTO.QTDAPROD.ordinal()));

        // Caso o item do grid esteja selecionado...
        if ((Boolean) (tabDet.getValor(i, DETALHAMENTO.MARCACAO.ordinal()))
            && qtdsugerida.floatValue() > 0) {
          try {

            PPGeraOP geraop = new PPGeraOP();
            geraop.setCodempop(Aplicativo.iCodEmp);
            geraop.setCodfilialop(Aplicativo.iCodFilial);
            geraop.setCodemppd((Integer) tabDet.getValor(i, DETALHAMENTO.CODEMPPD.ordinal()));
            geraop.setCodfilialpd((Integer) tabDet.getValor(i, DETALHAMENTO.CODFILIALPD.ordinal()));
            geraop.setCodprod((Integer) tabDet.getValor(i, DETALHAMENTO.CODPROD.ordinal()));
            geraop.setQtdSugProdOp(
                (BigDecimal) tabDet.getValor(i, DETALHAMENTO.QTDAPROD.ordinal()));
            geraop.setDtFabOp(
                Funcoes.strDateToDate(
                    (String) tabDet.getValor(i, DETALHAMENTO.DTFABROP.ordinal())));
            geraop.setSeqest((Integer) tabDet.getValor(i, DETALHAMENTO.SEQEST.ordinal()));

            ResultSet rs = daopush.geraOP(geraop);

            if (rs.next()) {
              ops.addElement(rs.getInt(1));
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }
      carregaItens();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      loading.stop();
      Funcoes.mensagemInforma(
          this, "As seguintes ordens de produção foram geradas:\n" + ops.toString());
    }
  }
Beispiel #22
0
 public float getFloat() throws SQLException {
   truncated_ = 0;
   outOfBounds_ = false;
   float f = value_.floatValue(); // @KBA
   // @KBD Changed to avoid optimization problem with JRE 1.3
   // @KBD if(value_.compareTo(FLOAT_MAX_VALUE) > 0 || value_.compareTo(FLOAT_MIN_VALUE) < 0)
   if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) // @KBA
   {
     // we don't count the fractional part of the number as truncation
     int length = value_.toBigInteger().toByteArray().length;
     truncated_ = length - 4;
     outOfBounds_ = true;
   }
   return f; // @KBC value_.floatValue();
 }
 protected Object toRetunType(BigDecimal result) {
   if (_expressionClass.isAssignableFrom(Boolean.class)) {
     return decodeBoolean(result);
   } else if (_expressionClass.isAssignableFrom(Double.class)) {
     return result.doubleValue();
   } else if (_expressionClass.isAssignableFrom(Float.class)) {
     return result.floatValue();
   } else if (_expressionClass.isAssignableFrom(Integer.class)) {
     return result.intValue();
   } else if (_expressionClass.isAssignableFrom(Long.class)) {
     return result.longValue();
   } else {
     return decodeString(result);
   }
 }
  // 18. purpose: getFloat with Defined Decimal Property
  public void testGetFloatConversionFromDefinedDecimalProperty() {
    // dataObject's type add int property
    property_c = new SDOProperty(aHelperContext);
    property_c.setName(PROPERTY_NAME_C);
    property_c.setType(SDOConstants.SDO_DECIMAL);
    type_c.addDeclaredProperty(property_c);
    dataObject_c._setType(type_c);

    float db = 12;
    BigDecimal bd = new BigDecimal(db);
    float delta = 0;
    dataObject_a.setBigDecimal(propertyPath_a_b_c, bd); // add it to instance list

    this.assertEquals(bd.floatValue(), dataObject_a.getFloat(propertyPath_a_b_c), delta);
  }
 private void processCoincidence(CoincidenceTO coincidenceTO) {
   BigDecimal matchPercent =
       MathUtils.divide(coincidenceTO.getTotalSeconds(), coincidenceTO.getCommercialDuration());
   if (matchPercent.floatValue() >= MIN_MATCH_PERCENT) {
     LOGGER.info(
         "Found jingle: {} with total match percent {}",
         coincidenceTO.getJingleName(),
         matchPercent);
     this.coincidenceBean.saveCoincidence(matchPercent, this.radioCode, coincidenceTO);
   } else {
     LOGGER.info(
         "Coincidence for jingle: {} not has enough match percent seconds {}",
         coincidenceTO.getJingleName(),
         matchPercent);
   }
 }
 /**
  * Calculate azimuth of a ray
  *
  * @param az0 azimuth at beginning of ray (binary angle)
  * @param az1 azimuth at end of ray (binary angle)
  * @return float azimuth in degrees with precision of two decimal
  */
 static float calcAz(short az0, short az1) {
   // output in deg
   float azim0 = calcAngle(az0);
   float azim1 = calcAngle(az1);
   float d = 0.0f;
   d = Math.abs(azim0 - azim1);
   if ((az0 < 0) & (az1 > 0)) {
     d = Math.abs(360.0f - azim0) + Math.abs(azim1);
   }
   double temp = azim0 + d * 0.5;
   if (temp > 360.0) {
     temp -= 360.0;
   }
   BigDecimal bd = new BigDecimal(temp);
   BigDecimal result = bd.setScale(2, RoundingMode.HALF_DOWN);
   return result.floatValue();
 }
 public float saldo(Conta conta, Date data) {
   StringBuffer sql = new StringBuffer();
   sql.append("select sum(l.valor * c.fator)");
   sql.append(" from LANCAMENTO l,");
   sql.append("   CATEGORIA c");
   sql.append(" where l.categoria = c.codigo");
   sql.append("  and l.conta = :conta");
   sql.append("  and l.data <= :data");
   SQLQuery query = this.session.createSQLQuery(sql.toString());
   query.setParameter("conta", conta.getConta());
   query.setParameter("data", data);
   BigDecimal saldo = (BigDecimal) query.uniqueResult();
   if (saldo != null) {
     return saldo.floatValue();
   }
   return 0f;
 }
Beispiel #28
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append("StudentCredit--> id: %d Student id: %d  IsActive: %x IsConsumed: %x");
   sb.append(" creditNote: %s creditDate: %s consumeNote: %s consumeDate: %s credit: %f");
   return String.format(
       sb.toString(),
       id.intValue(),
       msdStudentId,
       isActive,
       isConsumed,
       creditNote,
       null != creditDate ? new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(creditDate) : "n/a",
       consumeNote,
       null != consumedDate
           ? new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(consumedDate)
           : "n/a",
       credit.floatValue());
 }
  private void displayChart(List<CategoryReportModel> categoriesModel, double totalSpent) {
    v_pie_chart.clearChart();
    for (CategoryReportModel categoryReportModel : categoriesModel) {
      String categoryTitle =
          Category.getCategoryTitle(categoryReportModel.getCategory(), getContext());
      if (categoryTitle != null) {
        int categoryColor = getCategoryColor(categoryReportModel.getCategory());

        double amount = categoryReportModel.getAmount();
        float expenseToTotal = Math.abs((float) ((amount / totalSpent) * TOTAL_PERCENTAGE_VALUE));
        BigDecimal roundExpenseToTotal =
            new BigDecimal(expenseToTotal).setScale(DECIMAL_NUMBER, BigDecimal.ROUND_HALF_UP);

        v_pie_chart.addPieSlice(
            new PieModel(categoryTitle, roundExpenseToTotal.floatValue(), categoryColor));
      }
    }
    v_pie_chart.animate();
  }
  public void testUpdateReal() throws Throwable {
    try {
      Statement stmt = con.createStatement();
      stmt.execute(createRealTab);
      boolean ret = stmt.execute(createUpdateReal);

      stmt.execute(insertRealTab);
      stmt.close();

    } catch (Exception ex) {
      fail(ex.getMessage());
      throw ex;
    }
    try {
      CallableStatement cstmt = con.prepareCall("{ call update_real_proc(?,?) }");
      BigDecimal val = new BigDecimal(intValues[0]);
      float x = val.floatValue();
      cstmt.setObject(1, val, Types.REAL);
      val = new BigDecimal(intValues[1]);
      cstmt.setObject(2, val, Types.REAL);
      cstmt.executeUpdate();
      cstmt.close();
      ResultSet rs = con.createStatement().executeQuery("select * from real_tab");
      assertTrue(rs.next());
      Float oVal = new Float(intValues[0]);
      Float rVal = new Float(rs.getObject(1).toString());
      assertTrue(oVal.equals(rVal));
      oVal = new Float(intValues[1]);
      rVal = new Float(rs.getObject(2).toString());
      assertTrue(oVal.equals(rVal));
      rs.close();
    } catch (Exception ex) {
      fail(ex.getMessage());
    } finally {
      try {
        Statement dstmt = con.createStatement();
        dstmt.execute(dropUpdateReal);
        dstmt.close();
      } catch (Exception ex) {
      }
    }
  }