Package java.text

Examples of java.text.DecimalFormat.format()


      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


     
      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))));
      }
    }
   
    public void testToMonthNumber(){
View Full Code Here

      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);
View Full Code Here

      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

                        "###,###,###,##0.0;(#,##0.0)");

                double i = Double.parseDouble(props.getProperty("size"));
                i = i / 1024.0;

                num = nf.format(i) + num;
            } catch (NumberFormatException e) {
            }

            return num;
        }
View Full Code Here

                BigDecimal resultF = BigDecimal.valueOf( (duration * 1.00) / (loops * 1.00) )
                        .setScale( 2, BigDecimal.ROUND_HALF_UP );
                DecimalFormat dcf = new DecimalFormat( "###.##" );

                msgs[0] = adapters[i].getClass().getName() + ';' + df.format( start ) + ';' + df.format( end ) + ';'
                        + duration + ";" + dcf.format( resultF );
                msgs[1] = "-1";

                if ( result == null || !(result instanceof ObjectBean)
                        || !((ObjectBean) result).getTheString().equals( "Accepted" ) )
                {
View Full Code Here

      int finishCount = event.getWorkItemRep().getFinishedWorkItemCount(activityInstId);
     
      double c = Double.parseDouble(String.valueOf(finishCount)) / total;

      DecimalFormat df1 = new DecimalFormat("##.0000"); // ##.0000%  百分比格式,后面不足2位的用0补齐
      String d = df1.format(c);
     
      double finishPercent = Double.parseDouble(d)*100;
     
      double mustPercent = activityXml.getFinishRequiredPercent();
      if(finishPercent >= mustPercent)
View Full Code Here

            boolean append = new File( outFile ).exists();
            BufferedWriter out = new BufferedWriter( new FileWriter( outFile, append ) );
            if ( !append ) out.write( header );
            out.write( "\r\n" );
            out.write( loops + ";" + df.format( start ) + ';' + df.format( end ) + ';' + duration + ";"
                    + dcf.format( resultF ) );
            out.close();
        }
        catch ( IOException e )
        {
            e.printStackTrace();
View Full Code Here

        return new ConversionResult(decimalValue);
    }

    public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        return decimalFormat.format(value);
    }

    protected final DecimalFormat getDecimalFormat(Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = null;
        if (formatCache != null)
View Full Code Here

  public void setBundlePriority(String bundleName, int priority) {
    Properties metadataProperties = getPropertiesWithoutResolvingRecursively(null, bundleName);
    if (priority > 999) { throw new AssertException(
        "Bundle priorities can not be higher than 999. The smaller the number, the higher the priority."); }
    NumberFormat formatter = new DecimalFormat("000");
    metadataProperties.setProperty(METADATA_BUNDLE_PRIORITY_KEY, formatter.format(priority));
    saveOrUpdateProperties(metadataProperties, null, bundleName);
  }

  /**
   * Set the key priority within the bundle. The smaller the number, the higher
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.