Package java.text

Examples of java.text.NumberFormat$NumberFormatGetter


   * @param size
   * @return String
   */
  public static String formatSize(long size) {

    NumberFormat formatter = NumberFormat.getInstance();
    formatter.setMaximumFractionDigits(1);
    formatter.setMinimumFractionDigits(1);

    float mbValue = size;
    String format;
    if (mbValue < 1024) {
      format = formatter.format(mbValue) + " KB";
    } else {
      if (mbValue < 1048576) {
        mbValue /= 1024;
        format = formatter.format(mbValue) + " KB";
      } else {
        if (mbValue < 109970456576L) {
          mbValue /= 1048576;
          format = formatter.format(mbValue) + " MB";
        } else {
          formatter.setMaximumFractionDigits(1);
          formatter.setMinimumFractionDigits(1);
          mbValue /= (float) 1048576;
          format = formatter.format(mbValue) + " KB";
        }
      }
    }
    return format;
  }
View Full Code Here


        JRadioButton optUseDefaultFormat;
    JRadioButton optUseLocaleDependendFormat;

    public FloatingPointOkJPanel()
    {
      NumberFormat numberFormat = NumberFormat.getInstance();
      numberFormat.setMaximumFractionDigits(5);

      optUseDefaultFormat =
        new JRadioButton(s_stringMgr.getString("floatingPointBase.useDefaultFormat", new Double(3.14159).toString()));
      optUseLocaleDependendFormat =
        new JRadioButton(s_stringMgr.getString("floatingPointBase.uselocaleDependendFormat", numberFormat.format(new Double(3.14159))));



      setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("floatingPointBase.typeBigDecimal")));
View Full Code Here

    }
    GetLocationResult result = new GetLocationResult();
    if (location.size() > 0) {
      String[] parts = location.get(0).split("\\s+");
      if (parts.length >= 2) {
        NumberFormat format = NumberFormat.getInstance(locale);
        try {
          Double x = format.parse(parts[0]).doubleValue();
          Double y = format.parse(parts[1]).doubleValue();

          result.setCoordinate(new Coordinate(x, y));
          List<String> canonical = new ArrayList<String>();
          canonical.add(parts[0] + " " + parts[1]);
          result.setCanonicalStrings(canonical);
View Full Code Here

        textValue = new NumberTextValue(textStr, null, null);
      }
    }
    else
    {
      NumberFormat numberFormat = getNumberFormat(getTextFormatFactoryClass(text), pattern, getTextLocale(text));
     
      Number value = null;
      if (textStr != null && textStr.length() > 0)
      {
        value = numberFormat.parse(textStr);
      }
      textValue = new NumberTextValue(textStr, value, pattern);
    }
    return textValue;
  }
View Full Code Here

  protected NumberFormat getNumberFormat(String formatFactoryClass, String pattern, Locale lc)
  {
    String key = formatFactoryClass
      + "|" + pattern
      + "|" + (lc == null ? "" : JRDataUtils.getLocaleCode(lc));
    NumberFormat numberFormat = (NumberFormat)numberFormatCache.get(key);
    if (numberFormat == null)
    {
      FormatFactory formatFactory = DefaultFormatFactory.createFormatFactory(formatFactoryClass);//FIXMEFORMAT cache this too
      numberFormat = formatFactory.createNumberFormat(pattern, lc);
      numberFormatCache.put(key, numberFormat);
View Full Code Here

  }
 
 
  public NumberFormat createNumberFormat(String pattern, Locale locale)
  {
    NumberFormat format = null;
    if (pattern != null && pattern.trim().length() > 0)
    {
      if (locale == null)
      {
        format = NumberFormat.getNumberInstance();
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);
  }
View Full Code Here

   */
  public void setKeyPriority(String bundleName, String key, 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("00");
    metadataProperties.setProperty(key + METADATA_KEY_PRIORITY_POSTFIX, formatter.format(priority));
    saveOrUpdateProperties(metadataProperties, null, bundleName);
  }
View Full Code Here

            double value = testValues[i];
            RationalNumber rational = RationalNumberUtilities
                    .getRationalNumber(value);
            double difference = Math.abs(value - rational.doubleValue());

            NumberFormat nf = DecimalFormat.getInstance();
            nf.setMaximumFractionDigits(15);

            Debug.debug("value", nf.format(value));
            Debug.debug("rational", rational);
            Debug.debug("difference", difference);
            Debug.debug();
        }
    }
View Full Code Here

    // FIXME use locale for formats
    if (tickLabelMask != null)
    {
      if (axis instanceof NumberAxis)
      {
        NumberFormat fmt = NumberFormat.getInstance();
        if (fmt instanceof DecimalFormat)
        {
          ((DecimalFormat) fmt).applyPattern(tickLabelMask);
        }
        ((NumberAxis)axis).setNumberFormatOverride(fmt);
      }
      else if (axis instanceof DateAxis)
      {
        DateFormat fmt;
        if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT"))
        {
          fmt = DateFormat.getDateInstance(DateFormat.SHORT);
        }
        else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM"))
        {
          fmt = DateFormat.getDateInstance(DateFormat.MEDIUM);
        }
        else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG"))
        {
          fmt = DateFormat.getDateInstance(DateFormat.LONG);
        }
        else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL"))
        {
          fmt = DateFormat.getDateInstance(DateFormat.FULL);
        }
        else
        {
          fmt = new SimpleDateFormat(tickLabelMask);
        }

        if (timeZone != null)
        {
          fmt.setTimeZone(timeZone);
        }
       
        ((DateAxis)axis).setDateFormatOverride(fmt);
      }
      // ignore mask for other axis types.
View Full Code Here

TOP

Related Classes of java.text.NumberFormat$NumberFormatGetter

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.