Package java.text

Examples of java.text.DecimalFormat$FastPathData


    BigDecimal oDec = getDecimal(sKey);

    if (oDec==null)
      return null;
    else {
    DecimalFormat oNumFmt = (DecimalFormat) NumberFormat.getNumberInstance(oLoc);
    oNumFmt.setMaximumFractionDigits(2);
    return oNumFmt.format(oDec);
    }
  } // getDecimalFormated
View Full Code Here


      throws ClassCastException, NumberFormatException,NullPointerException,
             IllegalArgumentException {
    if (isNull(sKey))
        return null;
      else
        return new DecimalFormat(sPattern).format(getDouble(sKey));
  }
View Full Code Here

    throws ClassCastException, NumberFormatException,NullPointerException,
           IllegalArgumentException {
    if (isNull(sKey))
      return null;
    else
      return new DecimalFormat(sPattern).format(getFloat(sKey));
  }
View Full Code Here

                  }
                }
                nfformat.setEnabled(true);
                lformatdigits.setEnabled(true);
                if (((Object[])currentAction.option)[1] instanceof DecimalFormat) {
                  DecimalFormat df = ((DecimalFormat)((Object[])currentAction.option)[1]);
                  if (format==1) nfformat.setValue(df.getMaximumFractionDigits());
                  else {
                    String pattern = df.toPattern();
                    int l =0;
                    l = pattern.indexOf('E') - pattern.indexOf('.');
                    if (l>0) l--; // number of characters between . and E
                    nfformat.setValue(l);
                  }
View Full Code Here

   }
 
  public static String formatSizeHumanReadable(long number) {
    String result = "";
   
    DecimalFormat formatter = new DecimalFormat("0");
    double d = (double)number;
    if (d>=1000) {
      result = " K";
      d = d / 1000d;
      formatter = new DecimalFormat("0.00");
    }
   
    if (d >= 1000) {
      d = d / 1000d;
      result = " M";
    }
    result = formatter.format(d) + result;
    return result;
  }
View Full Code Here

  // ---------------------------------------------------------------------------

  public void setCurrencyFormat(String sFormat) throws NullPointerException {
    sCurrencyFormat = sFormat;
    oCurrencyFormat = new DecimalFormat(sFormat);
    oCurrencyFieldP = new FieldPosition(NumberFormat.FRACTION_FIELD);
    oCurrencyBuffer = new StringBuffer();
  }
View Full Code Here

                                                         0f),
                                        null);
        
        FontRenderContext columnTopfrc = null;
        LineMetrics lm = null;
        DecimalFormat df = null;
        Rectangle2D fontRec = null;
        String columnTop = null;
        if (barTopFormat != null) {
            g.setFont(barTopFont);
            columnTopfrc = new FontRenderContext(null, false, false);
View Full Code Here

   */
  public static BigDecimal round2 (BigDecimal oDec) {
    if (null==oDec) return null;
    if (null==oFmt2) {
      // oFmt2 = new DecimalFormat("#0.00");
    oFmt2 = new DecimalFormat();
    oFmt2.setMaximumFractionDigits(2);
    }
   
    return new BigDecimal (oFmt2.format(oDec.doubleValue()));
  }
View Full Code Here

    if (null==oDecVal) {
      return null;
    } else {
      if (oDecFmt==null) {
        oDecFmt = new DecimalFormat(sPattern);
        return oDecFmt.format(oDecVal.doubleValue());
      } else {
        if (oDecFmt.toPattern().equals(sPattern)) {
          return oDecFmt.format(oDecVal.doubleValue());
        } else {
          oDecFmt = new DecimalFormat(sPattern);
          return oDecFmt.format(oDecVal.doubleValue());
        }
      }
    }
  } // getDecimalFormated
View Full Code Here

    String sNodeName;
    Object oColValue;
    Class oColClass, ClassString = null, ClassDateTime = null, ClassTimeStamp = null,
                     ClassBigDecimal = null, ClassDouble = null, ClassFloat = null;
    SimpleDateFormat oXMLDate;
    DecimalFormat oDecFmt = null;

    if (sDateFormat==null)
      oXMLDate = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
    else if (sDateFormat.length()==0)
      oXMLDate = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
    else
      oXMLDate = new SimpleDateFormat(sDateFormat);

    if (null!=sDecimalFormat) {
      if (sDecimalFormat.length()>0)
        oDecFmt = new DecimalFormat(sDecimalFormat);
    } // fi

    if (DebugFile.trace) {
      DebugFile.writeln("Begin DBSubset.toXML(" + sNode + ")");
      DebugFile.incIdent();
    }

    try {
      ClassString = Class.forName("java.lang.String");
      ClassDateTime = Class.forName("java.util.Date");
      ClassTimeStamp = Class.forName("java.sql.Timestamp");
      ClassBigDecimal = Class.forName("java.math.BigDecimal");
      ClassDouble = Class.forName("java.lang.Double");
      ClassFloat = Class.forName("java.lang.Float");
    } catch (ClassNotFoundException ignore) { }

    if (oResults!=null) {

      sNodeName = (null!=sNode ? sNode : sTable);

      iRowCount = oResults.size();
      strBuff = new StringBuffer(256*iRowCount);

      strTok = new StringTokenizer(sColList,",");
      iTokCount = strTok.countTokens();
      String[] Labels = new String[iTokCount];

      for (int iTok=0; iTok<iTokCount; iTok++) {
        sLabel = strTok.nextToken();
        iAs = sLabel.toUpperCase().indexOf(" AS ");
        if (-1!=iAs) sLabel = sLabel.substring(iAs+4);
        iDot = sLabel.indexOf('.');
        if (-1!=iDot) sLabel = sLabel.substring(++iDot);
        Labels[iTok] = sLabel.trim();
      } // next

      for (int iRow=0; iRow<iRowCount; iRow++)
        {
        vRow = (Vector) oResults.get(iRow);
        iCol = 0;
        strBuff.append(sIdent + "<" + sNodeName + ">\n");
        while (iCol<iColCount)
          {
          strBuff.append(sIdent + "  <" + Labels[iCol] + ">");
          oColValue = vRow.get(iCol);
          if (null!=oColValue) {
            oColClass = oColValue.getClass();

            if (oColClass.equals(ClassString) && !Labels[iCol].startsWith("gu_"))
              strBuff.append("<![CDATA[" + oColValue + "]]>");

            else if (oColClass.equals(ClassDateTime))
              strBuff.append (oXMLDate.format((java.util.Date) oColValue));

            else if (oColClass.equals(ClassTimeStamp))
              strBuff.append (oXMLDate.format(new Date (((java.sql.Timestamp) oColValue).getTime())));

            else if (oColClass.equals(ClassBigDecimal) && (oDecFmt!=null))
              strBuff.append (oDecFmt.format((java.math.BigDecimal) oColValue));

            else if (oColClass.equals(ClassDouble) && (oDecFmt!=null))
              strBuff.append (oDecFmt.format(((java.lang.Double) oColValue).doubleValue()));

            else if (oColClass.equals(ClassFloat) && (oDecFmt!=null))
              strBuff.append (oDecFmt.format((double)((java.lang.Float) oColValue).floatValue()));

            else if (oColClass.equals(getClass()))
              strBuff.append ("<"+getColumnName(iCol)+"s>\n"+((DBSubset)oColValue).toXML(sIdent+"  ", getColumnName(iCol), sDateFormat, sDecimalFormat)+"\n</"+getColumnName(iCol)+"s>\n");

            else
View Full Code Here

TOP

Related Classes of java.text.DecimalFormat$FastPathData

Copyright © 2018 www.massapicom. 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.