Examples of DecimalFormat


Examples of java.text.DecimalFormat

    public static String formatNumber(final double number) {
        return formatNumber(number, true);
    }

    public static String formatNumber(final double number, boolean commaSep) {
        DecimalFormat f = new DecimalFormat(commaSep ? "#,###.###" : "###.###");
        f.setDecimalSeparatorAlwaysShown(false);
        return f.format(number);
    }
View Full Code Here

Examples of java.text.DecimalFormat

    switch( variable )
    {
      case 'a':
        return getShortStateString(dm.getState());
      case 'c':
        DecimalFormat df = new DecimalFormat("000.0%");
        return df.format(dm.getStats().getCompleted() / 1000.0);
      case 't':
        if (dm.getState() == DownloadManager.STATE_ERROR)
          return dm.getErrorDetails();
        else {
          if (dm.getDisplayName() == null)
            return "?";
          else
            return dm.getDisplayName();
        }
      case 'z':
        return DisplayFormatters.formatByteCountToKiBEtc(dm.getSize());
      case 'e':
        return DisplayFormatters.formatETA(dm.getStats().getETA());
      case 'r':
        long to = 0;
        long tot = 0;
        if (dm.getDiskManager() != null) {
          DiskManagerFileInfo files[] = dm.getDiskManager().getFiles();
          if (files != null) {
            if (files.length>1) {
              int c=0;
              for (int i = 0; i < files.length; i++) {
                if (files[i] != null) {
                  if (!files[i].isSkipped()) {
                    c += 1;
                    tot += files[i].getLength();
                    to += files[i].getDownloaded();
                  }
                }
              }
              if (c == files.length)
                tot = 0;
            }
          }
        }
        DecimalFormat df1 = new DecimalFormat("000.0%");
        if (tot > 0) {
          return "      ("+df1.format(to * 1.0 / tot)+")";
        } else
          return "\t";
      case 'd':
        return DisplayFormatters.formatByteCountToKiBEtcPerSec(dm.getStats().getDataReceiveRate());
      case 'u':
View Full Code Here

Examples of java.text.DecimalFormat

          tmp = "!";
        out.print(tmp + ") ");
        if (files[i] != null) {
          long fLen = files[i].getLength();
          if (fLen > 0) {
            DecimalFormat df = new DecimalFormat("000.0%");
            out.print(df.format(files[i].getDownloaded() * 1.0
                / fLen));
            out.println("\t" + files[i].getFile(true).getName());
          } else
            out.println("Info not available.");
        } else
View Full Code Here

Examples of java.text.DecimalFormat

        printStat("SELECT", SELECT_COUNT);
    }

    private static void printStat(String name, AtomicLong value) {
        if (value.get() > 0) {
            DecimalFormat df = new DecimalFormat("###,###,###,###");
            out.println(name + "=" + df.format(CREATE_COUNT.get()));
        }
    }
View Full Code Here

Examples of java.text.DecimalFormat

    final int digits = (int) Math.round(Math.log(value.length) / Math.log(10) + 0.5);
    final StringBuffer formatString = new StringBuffer();
    for (int i = 0; i < digits; i++)
      formatString.append('0');
    formatString.append(": ");
    final DecimalFormat format = new DecimalFormat(formatString.toString());
   
    StringBuffer retVal = new StringBuffer();
    retVal.append(format.format(0));
    int i = -1;
    for(int x = 0; x < value.length; x++) {
      if (++i == bytesPerLine) {
        retVal.append('\n');
        retVal.append(format.format(x));
        i = 0;
      }
      retVal.append(toHex(value[x]));
      retVal.append(", ");
    }
View Full Code Here

Examples of java.text.DecimalFormat

        oForm.setActualcloseyear(strYear);
      }
     
      oForm.setOpportunitytypeid((new Integer(oVO.getOpportunityTypeID())).toString());
      oForm.setProbabilityid((new Integer(oVO.getProbability())).toString());
      DecimalFormat currencyFormat = new DecimalFormat("###,###,##0.00");
      String actualAmount = currencyFormat.format(oVO.getActualAmount());
      oForm.setTotalamount(actualAmount);
     
      String forecast = currencyFormat.format(oVO.getForecastedAmount());
      oForm.setForecastedamount(forecast);
     
      if (oVO.getCreateddate() != null) {
        Timestamp date = (Timestamp)oVO.getCreateddate();
       
View Full Code Here

Examples of java.text.DecimalFormat

      ItemLines itemLines = (ItemLines) hm.get("itemLines");

      if (itemLines != null)
      {
        itemLines.calculate();
        DecimalFormat currencyFormat = new DecimalFormat("#,##0.00");
        DecimalFormat rawCurrencyFormat = new DecimalFormat("#0.00");
        DecimalFormat wholeNumberFormat = new DecimalFormat("#0");

        java.util.Set listkey = itemLines.keySet();
        java.util.Iterator it =  listkey.iterator();

        int i=1;
        int itemNum = 0;

        if(!it.hasNext()){
          Items = Items + "<tr>\n";
          Items = Items + "<td colspan=\"5\" align=\"center\">No items found</td>\n";
          Items = Items + "</tr>\n";
        }
        while (it.hasNext())
        {
          ItemElement ele  = (ItemElement)itemLines.get(it.next());
          String lineStatus = ele.getLineStatus();
          if (lineStatus == null)
          {
            lineStatus = "";
          } //end of if statement (lineStatus == null)

               if (!lineStatus.equals("Deleted")) {

          IntMember lineid = (IntMember)ele.get("LineId");
          IntMember itemid = (IntMember)ele.get("ItemId");
          StringMember sku = (StringMember)ele.get("SKU");
          IntMember qty   = (IntMember)ele.get("Quantity");
          FloatMember priceEach = (FloatMember)ele.get("Price");
          FloatMember priceExe = (FloatMember)ele.get("PriceExtended");

          StringMember desc  = (StringMember)ele.get("Description");
          FloatMember taxAmount = (FloatMember)ele.get("TaxAmount");

          String quantity;
          String priceEachString;
          try
          {
            float tempFloat = (currencyFormat.parse(qty.getDisplayString())).floatValue();
            quantity = wholeNumberFormat.format(new Float(tempFloat));
          } //end of try block
          catch (Exception exception)
          {
            quantity = "0";
          } //end of catch block (Exception)

          try
          {
            float priceEachValue = ((Float) priceEach.getMemberValue()).floatValue();
            priceEachString = rawCurrencyFormat.format(new Float(priceEachValue));
          } //end of try block
          catch (Exception exception)
          {
            priceEachString = "0.00";
          } //end of catch block (Exception)


          Items = Items + "<tr>\n";
          Items = Items + "<td width=\"15%\">&nbsp;"+sku.getDisplayString()+"</td>\n";
          Items = Items + "<td width=\"40%\">&nbsp;"+desc.getDisplayString()+"</td>\n";
          Items = Items + "<td width=\"15%\">&nbsp;"+quantity+"</td>\n";
          Items = Items + "<td width=\"15%\" align=\"right\">&nbsp;$"+priceEachString+"</td>\n";
          Items = Items + "<td width=\"15%\" align=\"right\">&nbsp;$"+priceExe.getDisplayString()+"</td>\n";
          Items = Items + "</tr>\n";
               }
        }//end of while


        String totalItems;
        try
        {
          totalItems = wholeNumberFormat.format(new Float(itemLines.getTotalItems()));
        } //end of try block
        catch (Exception exception)
        {
          totalItems = "0";
        }
View Full Code Here

Examples of java.text.DecimalFormat

      if (itemForm.getVendorid() != null && itemForm.getVendorid().length() > 0)
      {
        itemVO.setVendorid(Integer.parseInt(itemForm.getVendorid()));
      } //end of if statement (itemForm.getVendorid() != null && itemForm.getVendorid().length() > 0)

      DecimalFormat nf = (DecimalFormat)DecimalFormat.getInstance();
      nf.setDecimalSeparatorAlwaysShown(false);
      if (itemForm.getPrice() != null && itemForm.getPrice().length() > 0)
      {
        double price = (nf.parse(itemForm.getPrice())).doubleValue();
        itemVO.setPrice(price);
      } //end of if statement (itemForm.getPrice() != null && itemForm.getPrice().length() > 0)
      if (itemForm.getCost() != null && itemForm.getCost().length() > 0)
      {
        double cost = (nf.parse(itemForm.getCost())).doubleValue();
        itemVO.setCost(cost);
      } //end of if statement (itemForm.getCost() != null && itemForm.getCost().length() > 0)
      if (itemForm.getLinktoinventory() != null && itemForm.getLinktoinventory().length() > 0)
      {
        itemVO.setLinkToInventory(itemForm.getLinktoinventory());
View Full Code Here

Examples of java.text.DecimalFormat

     
      if (itemForm.getVendorid() != null && itemForm.getVendorid().length() > 0){
        itemVO.setVendorid(Integer.parseInt(itemForm.getVendorid()));
      }
     
      DecimalFormat nf = (DecimalFormat)DecimalFormat.getInstance();
      nf.setDecimalSeparatorAlwaysShown(false);

      if (itemForm.getPrice() != null && itemForm.getPrice().length() > 0){
        double price = (nf.parse(itemForm.getPrice())).doubleValue();
        itemVO.setPrice(price);
      }
     
      if (itemForm.getCost() != null && itemForm.getCost().length() > 0){
        double cost = (nf.parse(itemForm.getCost())).doubleValue();
        itemVO.setCost(cost);
      }
     
      if (itemForm.getLinktoinventory() != null && itemForm.getLinktoinventory().length() > 0){
        itemVO.setLinkToInventory(itemForm.getLinktoinventory());
View Full Code Here

Examples of java.text.DecimalFormat

      height = h;
    }
}

protected DecimalFormat getNumberFormatterFor(String formatString) {
    DecimalFormat formatter =
  (DecimalFormat)decimalFormatters.get(formatString);
    if (formatter == null) {
  formatter = new DecimalFormat(formatString);
  decimalFormatters.put(formatString, formatter);
    }
    return formatter;
}
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.