Package java.text

Examples of java.text.DecimalFormat


        }
        else
        {
          if (getLineTicksLabelFormat() != null)
          {
            final DecimalFormat formatter = new DecimalFormat
                (getLineTicksLabelFormat(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
            numberAxis.setNumberFormatOverride(formatter);
          }
        }
      }
View Full Code Here


        DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault());
        symbols.setGroupingSeparator(groupingChar);
        symbols.setInternationalCurrencySymbol("EUR");

        DecimalFormat format = new DecimalFormat("###,###", symbols);
        format.setGroupingSize(3);
        return format.format(l) + " bytes";
    }
View Full Code Here

        DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault());
        symbols.setDecimalSeparator(decimalSep);
        symbols.setGroupingSeparator(groupingSep);
       
       
        DecimalFormat format = new DecimalFormat("###,###.00", symbols);
        format.setGroupingSize(3);
        return format.format(d);
    }
View Full Code Here

        {
          numberAxis.setNumberFormatOverride(getDomainTickFormat());
        }
        else if (getDomainTickFormatString() != null)
        {
          final DecimalFormat formatter = new DecimalFormat
              (getDomainTickFormatString(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
          numberAxis.setNumberFormatOverride(formatter);
        }
      }
    }
    else if (domainAxis instanceof DateAxis)
    {
      final DateAxis numberAxis = (DateAxis) domainAxis;

      if (getDomainPeriodCount() > 0 && getDomainTimePeriod() != null)
      {
        if (getDomainTickFormatString() != null)
        {
          final SimpleDateFormat formatter = new SimpleDateFormat
              (getDomainTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale()));
          numberAxis.setTickUnit
              (new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()), (int) getDomainPeriodCount(), formatter));
        }
        else
        {
          numberAxis.setTickUnit
              (new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()), (int) getDomainPeriodCount()));
        }
      }
    }

    if (domainAxis != null)
    {
      domainAxis.setLabel(getDomainTitle());
      if (getDomainTitleFont() != null)
      {
        domainAxis.setLabelFont(getDomainTitleFont());
      }
      domainAxis.setVerticalTickLabels(isDomainVerticalTickLabels());
      if (getDomainTickFont() != null)
      {
        domainAxis.setTickLabelFont(getDomainTickFont());
      }
      if (getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND)
      {
        domainAxis.setLowerBound(getDomainMinimum());
      }
      if (getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND)
      {
        domainAxis.setUpperBound(getDomainMaximum());
      }
    }

    final ValueAxis rangeAxis = plot.getRangeAxis();
    if (rangeAxis instanceof NumberAxis)
    {
      final NumberAxis numberAxis = (NumberAxis) rangeAxis;

      if (getRangePeriodCount() > 0)
      {
        if (getRangeTickFormat() != null)
        {
          numberAxis.setTickUnit(new NumberTickUnit(getRangePeriodCount(), getRangeTickFormat()));
        }
        else if (getRangeTickFormatString() != null)
        {
          final FastDecimalFormat formatter = new FastDecimalFormat
              (getRangeTickFormatString(), getResourceBundleFactory().getLocale());
          numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount(), formatter));
        }
        else
        {
          numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount()));
        }
      }
      else
      {
        if (getRangeTickFormat() != null)
        {
          numberAxis.setNumberFormatOverride(getRangeTickFormat());
        }
        else if (getRangeTickFormatString() != null)
        {
          final DecimalFormat formatter = new DecimalFormat
              (getRangeTickFormatString(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
          numberAxis.setNumberFormatOverride(formatter);
        }
      }
    }
View Full Code Here

            if (pattern.indexOf('N') != -1) {
                pattern = pattern.replace('N', '#');
            }

            DecimalFormat format = new DecimalFormat(pattern);

            return format.format(number.doubleValue());

        } else {
            return getEmptyString();
        }
    }
View Full Code Here

     * @param number the number to format
     * @return the formatted decimal number
     */
    public String decimal(Number number) {
        if (number != null) {
            DecimalFormat format = new DecimalFormat();

            return format.format(number.doubleValue());

        } else {
            return getEmptyString();
        }
    }
View Full Code Here

        return formattingProperties.getProperty("long.number.format", "###############");
    }

    public static void setDefaultLongNumberFormatterPattern(String defaultLongNumberFormatterPattern) {
        formattingProperties.setProperty("long.number.format", defaultLongNumberFormatterPattern);
        defaultLongNumberFormatter = new DecimalFormat(defaultLongNumberFormatterPattern);
    }
View Full Code Here

        return formattingProperties.getProperty("decimal.number.format", "###############.##########");
    }

    public static void setDefaultDecimalNumberFormatterPattern(String defaultDecimalNumberFormatterPattern) {
        formattingProperties.getProperty("decimal.number.format", defaultDecimalNumberFormatterPattern);
        defaultDecimalNumberFormatter = new DecimalFormat(defaultDecimalNumberFormatterPattern);
    }
View Full Code Here

  public static final Object[] p_format = new Object[] { "format" };
  public Any m_format(Context context, String format)
  {
    try {
      DecimalFormatSymbols dfsymbols = new DecimalFormatSymbols(context.getLocale());
      DecimalFormat df = new DecimalFormat(format, dfsymbols);
      if (typeOf() == IS_INT) {
        return Any.create(df.format(toLong()));
      } else {
        return Any.create(df.format(toDouble()));
      }
    } catch (IllegalArgumentException e) {
      throw context.BadParameter(e.getMessage());
    }
  }
View Full Code Here

     */
    protected String getFileNameForTime(long l) {
        Calendar cal = new GregorianCalendar();
        cal.setTimeInMillis(l);

        DecimalFormat twoDigits = new DecimalFormat("00");

        String tMarker = Integer.toString(cal.get(Calendar.YEAR))
                + twoDigits.format(cal.get(Calendar.MONTH) + 1)
                + twoDigits.format(cal.get(Calendar.DAY_OF_MONTH))
                + twoDigits.format(cal.get(Calendar.HOUR_OF_DAY))
                + twoDigits.format(cal.get(Calendar.MINUTE))
                + twoDigits.format(cal.get(Calendar.SECOND));

        return tMarker + "."
                + getImageFormatter().getFormatLabel().toLowerCase();
    }
View Full Code Here

TOP

Related Classes of java.text.DecimalFormat

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.