Examples of NumberFormat


Examples of java.text.NumberFormat

   * @param oLocale Locale used for formatting
   * @return String
   * @see <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Locale.html">java.util.Locale</a>
   */
  public static String formatCurrency (BigDecimal oDec, String sCurrency, Locale oLocale) {
    NumberFormat oFmtC;
    if (null==oDec) return null;

    if (null==sCurrency) {
      oCurr = Currency.getInstance(oLocale==null ? Locale.getDefault() : oLocale);
    }
    else if (!sCurrency.equals(sCurr)) {
      oCurr = Currency.getInstance(sCurrency);
    }
    if (null==oLocale)
      oFmtC = NumberFormat.getCurrencyInstance(Locale.getDefault());
    else
      oFmtC = NumberFormat.getCurrencyInstance(oLocale);
    oFmtC.setCurrency(oCurr);
    return oFmtC.format(oDec.doubleValue());
  } // formatCurrency
View Full Code Here

Examples of java.text.NumberFormat

      oLoc = new Locale(sLanguage,sCountry);
    else if (null!=sLanguage)
      oLoc = new Locale(sLanguage);
    else
      oLoc = Locale.getDefault();
    NumberFormat oFmtC = NumberFormat.getCurrencyInstance(oLoc);
    oFmtC.setCurrency(currencyCode().currency());
    return oFmtC.format(doubleValue());
  } // format
View Full Code Here

Examples of java.text.NumberFormat

    // Systemspeziefischen Zeilenumbruch holen
    String lineSeparator = RegainToolkit.getLineSeparator();

    // Statistik ausgeben
    StringBuffer buffer = new StringBuffer(mName + ":");
    NumberFormat integerFormat = NumberFormat.getInstance();
    integerFormat.setMaximumFractionDigits(0);
    if (abortedMeasureCount > 0) {
      buffer.append(lineSeparator);

      appendLabel(buffer, "Aborted " + mUnit, minLabelLength);
      buffer.append(integerFormat.format(abortedMeasureCount) + " " + mUnit + " (");

      // Ausgeben, wieviel % der Messungen fehl schlugen
      int total = abortedMeasureCount + measureCount;
      double errorPercent = (double) abortedMeasureCount / (double) total;
      buffer.append(RegainToolkit.toPercentString(errorPercent));

      buffer.append(")");
    }
    if (measureCount > 0) {
      buffer.append(lineSeparator);

      appendLabel(buffer, "Completed " + mUnit, minLabelLength);
      buffer.append(integerFormat.format(measureCount) + " " + mUnit + lineSeparator);

      appendLabel(buffer, "Total time", minLabelLength);
      buffer.append(RegainToolkit.toTimeString(totalTime) + lineSeparator);

      appendLabel(buffer, "Total data", minLabelLength);
      buffer.append(RegainToolkit.bytesToString(totalBytes) + lineSeparator);

      appendLabel(buffer, "Average time", minLabelLength);
      buffer.append(RegainToolkit.toTimeString(averageTime) + lineSeparator);

      appendLabel(buffer, "Average data", minLabelLength);
      buffer.append(RegainToolkit.bytesToString(averageBytes) + lineSeparator);

      appendLabel(buffer, "Data rate", minLabelLength);
      buffer.append(RegainToolkit.bytesToString(dataRatePerSec) + "/sec" + lineSeparator);

      appendLabel(buffer, "Output", minLabelLength);
      if (countsPerMinute > 10) {
        // No decimals when the count is high
        buffer.append(integerFormat.format(countsPerMinute) + " " + mUnit + "/min");
      } else {
        NumberFormat floatingFormat = NumberFormat.getInstance();
        floatingFormat.setMinimumFractionDigits(2);
        floatingFormat.setMaximumFractionDigits(2);
        buffer.append(floatingFormat.format(countsPerMinute) + " " + mUnit + "/min");
      }
    }

    return buffer.toString();
  }
View Full Code Here

Examples of java.text.NumberFormat

      list.toArray(mExtensionArr);

      if (mLog.isDebugEnabled()) {
        double duration = (double) (System.currentTimeMillis() - startTime) / 1000.0;

        NumberFormat format = NumberFormat.getInstance();
        format.setMinimumFractionDigits(2);
        format.setMaximumFractionDigits(2);

        mLog.debug("Getting the supported extensions of the IfilterPreparator took "
            + format.format(duration) + " secs");
      }
    }

    return mExtensionArr;
  }
View Full Code Here

Examples of java.text.NumberFormat

    Document doc=new Document();
    Enumeration nameIter=prop.propertyNames();
    while(nameIter.hasMoreElements()){
      String name=(String)nameIter.nextElement();
      NumberFormat format=formatterHash.get(name);
      String val=prop.getProperty(name);
     
      String[] vals=val.split(",");
      for (int i=0;i<vals.length;++i){
        if (vals[i]!=null && vals[i].length()>0){
          if (format!=null){
            vals[i]=format.format(Double.parseDouble(vals[i]));
          }
          doc.add(new Field(name,vals[i],Field.Store.NO,Field.Index.NOT_ANALYZED,Field.TermVector.NO));
        }
      } 
    }
View Full Code Here

Examples of java.text.NumberFormat

      }

      if (mLog.isDebugEnabled()) {
        double duration = (double) (System.currentTimeMillis() - startTime) / 1000.0;

        NumberFormat format = NumberFormat.getInstance();
        format.setMinimumFractionDigits(2);
        format.setMaximumFractionDigits(2);

        mLog.debug("..." + toCommand(commandArr) + " finished ("
            + format.format(duration) + " secs)");
      }

      if (exitCode != 0) {
        throw new RegainException("Native command exited with exit code "
            + exitCode + ": '" + toCommand(commandArr) + "'");
View Full Code Here

Examples of java.text.NumberFormat

      assertEquals("2011", Util.toFourDigitYear("11", 2001));
     
      int thisYear = Calendar.getInstance().get(Calendar.YEAR);
      int d2 = thisYear % 100;

      NumberFormat f = new DecimalFormat("00");
     
      for (int i = 0; i <= 30; i++){
        assertTrue("" + i, thisYear <= Integer.parseInt(Util.toFourDigitYear(f.format((d2 + i) % 100))));
      }
      for (int i = 0; i < 70; i++){
        assertTrue("" + i, thisYear >= Integer.parseInt(Util.toFourDigitYear(f.format((d2 - i + 100) % 100))));
      }
    }
View Full Code Here

Examples of java.text.NumberFormat

        private void printScriptExecDetails(int statementCount,
                double executionLength,
                double outputLength,
                double totalLength)
        {
            final NumberFormat nbrFmt = NumberFormat.getNumberInstance();

            Object[] args = new Object[] {
                Integer.valueOf(statementCount),
                nbrFmt.format(totalLength),
                nbrFmt.format(executionLength),
                nbrFmt.format(outputLength)
            };

            //i18n[SQLResultExecuterPanel.scriptQueryStatistics=Executed {0}
            //queries; elapsed time (seconds) - Total: {1}, SQL query: {2},
            //Building output: {3}]
View Full Code Here

Examples of java.text.NumberFormat

                Integer numberResultRowsRead,
                double executionLength,
                double outputLength,
                double totalLength)
        {
            final NumberFormat nbrFmt = NumberFormat.getNumberInstance();

            Object[] args = new Object[] {
                    Integer.valueOf(processedStatementCount),
                    Integer.valueOf(statementCount),
                    numberResultRowsRead == null ? 0: numberResultRowsRead,
                    nbrFmt.format(totalLength),
                    nbrFmt.format(executionLength),
                    nbrFmt.format(outputLength)
            };

            //i18n[SQLResultExecuterPanel.queryStatistics=Query {0} of {1}
            //elapsed time (seconds) - Total: {2}, SQL query: {3},
            //Building output: {4}]
View Full Code Here

Examples of java.text.NumberFormat

  public static String getSize(int bytes) {
    if (bytes > 0) {
      double mb = bytes / (1024d * 1024d);
      double kb = bytes / 1024d;

      NumberFormat format = new DecimalFormat(Messages.OwlUI_SIZE_FORMAT);

      if (mb >= 1)
        return NLS.bind(Messages.OwlUI_N_MB, format.format(mb));

      if (kb >= 1)
        return NLS.bind(Messages.OwlUI_N_KB, format.format(kb));

      return NLS.bind(Messages.OwlUI_N_BYTES, bytes);
    }

    return null;
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.