Package java.text

Examples of java.text.DecimalFormat.toPattern()


  public void check1Min(Queue<Packet> results) {
    for (File file : roots) {
      NumberFormat format = NumberFormat.getIntegerInstance();
      if (format instanceof DecimalFormat) {
        DecimalFormat decf = (DecimalFormat) format;
        decf.applyPattern(decf.toPattern() + " KB");
      }
      NumberFormat formp = NumberFormat.getPercentInstance();
      formp.setMaximumFractionDigits(2);
      double percent = new Long(file.getUsableSpace()).doubleValue() /
              new Long(file.getTotalSpace()).doubleValue();
View Full Code Here


    if (note.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
      log.info("Usage threshold exceeded, sending notification.");
      NumberFormat format = NumberFormat.getIntegerInstance();
      if (format instanceof DecimalFormat) {
        DecimalFormat decf = (DecimalFormat) format;
        decf.applyPattern(decf.toPattern() + " KB");
      }
      MemoryPoolMXBean memoryPoolMXBean = (MemoryPoolMXBean) handback;
      String message = "Threshold " +
              format.format(memoryPoolMXBean.getUsageThreshold() / 1024) +
              " for memory pool: " + memoryPoolMXBean.getName() +
View Full Code Here

  public String getState() {
    NumberFormat format = NumberFormat.getIntegerInstance();
    if (format instanceof DecimalFormat) {
      DecimalFormat decf = (DecimalFormat) format;
      decf.applyPattern(decf.toPattern() + " KB");
    }
    NumberFormat formp = NumberFormat.getPercentInstance();
    formp.setMaximumFractionDigits(2);
    StringBuilder sb = new StringBuilder();
    List<MemoryPoolMXBean> memPools = ManagementFactory.getMemoryPoolMXBeans();
View Full Code Here

            {
              final DecimalFormat df = (DecimalFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else
          {
            final String[] fields = fmt.getFields();
View Full Code Here

        if(getDecimalPlaces(currency) == 0) {
            numberFormat.setParseIntegerOnly(true);
        }
        if(international && numberFormat instanceof DecimalFormat) {
            DecimalFormat df = (DecimalFormat) numberFormat;
            df.applyPattern(df.toPattern().replaceAll("\u00A4+", "\u00A4\u00A4")); // TODO This seems to be less efficient than I'd like
        }
        return numberFormat;
    }

    @Override
View Full Code Here

            return parsedValue;
        }

        // Re-parse using a pattern without the currency symbol
        DecimalFormat decimalFormat = (DecimalFormat)formatter;
        String pattern = decimalFormat.toPattern();
        if (pattern.indexOf(CURRENCY_SYMBOL) >= 0) {
            StringBuffer buffer = new StringBuffer(pattern.length());
            for (int i = 0; i < pattern.length(); i++) {
                if (pattern.charAt(i) != CURRENCY_SYMBOL) {
                    buffer.append(pattern.charAt(i));
View Full Code Here

            return parsedValue;
        }

        // Re-parse using a pattern without the percent symbol
        DecimalFormat decimalFormat = (DecimalFormat)formatter;
        String pattern = decimalFormat.toPattern();
        if (pattern.indexOf(PERCENT_SYMBOL) >= 0) {
            StringBuffer buffer = new StringBuffer(pattern.length());
            for (int i = 0; i < pattern.length(); i++) {
                if (pattern.charAt(i) != PERCENT_SYMBOL) {
                    buffer.append(pattern.charAt(i));
View Full Code Here

        DecimalFormat format = (DecimalFormat) NumberFormat
                .getIntegerInstance();

        assertEquals(
                "Test1: NumberFormat.getIntegerInstance().toPattern() returned wrong pattern",
                "#,##0", format.toPattern());
        assertEquals(
                "Test2: NumberFormat.getIntegerInstance().format(35.76) returned wrong value",
                "36", format.format(35.76));
        assertEquals(
                "Test3: NumberFormat.getIntegerInstance().parse(\"35.76\") returned wrong number",
View Full Code Here

        DecimalFormat format = (DecimalFormat) NumberFormat
                .getIntegerInstance(usLocale);
        assertEquals(
                "Test1: NumberFormat.getIntegerInstance().toPattern() returned wrong pattern",
                "#,##0", format.toPattern());
        assertEquals(
                "Test2: NumberFormat.getIntegerInstance().format(-35.76) returned wrong value",
                "-36", format.format(-35.76));
        assertEquals(
                "Test3: NumberFormat.getIntegerInstance().parse(\"-36\") returned wrong number",
View Full Code Here

        // try with a locale that has a different integer pattern
        format = (DecimalFormat) NumberFormat.getIntegerInstance(arLocale);
        assertEquals(
                "Test7: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).toPattern() returned wrong pattern",
                "#,##0;#,##0-", format.toPattern());
        assertEquals(
                "Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-35.76) returned wrong value",
                "36-", format.format(-35.76));
        assertEquals(
                "Test9: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parse(\"-36-\") returned wrong number",
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.