Example usage for java.text NumberFormat getInstance

List of usage examples for java.text NumberFormat getInstance

Introduction

In this page you can find the example usage for java.text NumberFormat getInstance.

Prototype

public static final NumberFormat getInstance() 

Source Link

Document

Returns a general-purpose number format for the current default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:com.liferay.portal.events.GarbageCollectorAction.java

public void run(HttpSession ses) throws ActionException {

    try {//w  ww.  j  a v  a  2 s  .co  m
        Runtime runtime = Runtime.getRuntime();

        NumberFormat nf = NumberFormat.getInstance();

        _log.debug("Before GC: " + nf.format(runtime.freeMemory()) + " free, "
                + nf.format(runtime.totalMemory()) + " total, and " + nf.format(runtime.maxMemory()) + " max");

        _log.debug("Running garbage collector");

        System.gc();

        _log.debug("After GC: " + nf.format(runtime.freeMemory()) + " free, " + nf.format(runtime.totalMemory())
                + " total, and " + nf.format(runtime.maxMemory()) + " max");
    } catch (Exception e) {
        throw new ActionException(e);
    }
}

From source file:org.gageot.excel.beans.BeanSetterImpl.java

protected BeanWrapper getWrapper(Object bean) {
    if (bean != currentBean) {
        currentBean = bean;/*from   w  w  w. j a va2s  .c o  m*/
        currentWrapper = PropertyAccessorFactory.forBeanPropertyAccess(currentBean);

        // To make sure that Double values can be converted into an int.
        //
        currentWrapper.registerCustomEditor(int.class,
                new CustomNumberEditor(Integer.class, NumberFormat.getInstance(), false));
    }

    return currentWrapper;
}

From source file:com.liferay.portal.events.LogMemoryUsageAction.java

public void run(HttpServletRequest req, HttpServletResponse res) throws ActionException {

    Runtime runtime = Runtime.getRuntime();

    NumberFormat nf = NumberFormat.getInstance();

    String freeMemory = nf.format(runtime.freeMemory());
    String totalMemory = nf.format(runtime.totalMemory());
    String maxMemory = nf.format(runtime.maxMemory());

    _log.debug("Memory Usage:\t" + freeMemory + "\t" + totalMemory + "\t" + maxMemory);
}

From source file:com.rapidminer.gui.plotter.charts.ParetoChartItemLabelGenerator.java

/**
 * Creates a new generator with a default number formatter.
 *//*from  w ww . jav  a  2s.c  o  m*/
public ParetoChartItemLabelGenerator(Map<String, String> itemLabels) {
    super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance());
    this.itemLabels = itemLabels;
}

From source file:com.anrisoftware.globalpom.format.point.PointFormat.java

/**
 * Uses the default decimal format to format the X and Y coordinates of a
 * point.//from  ww  w .  j av  a  2  s  .com
 */
public PointFormat() {
    this(new PointFormatLogger(), NumberFormat.getInstance());
}

From source file:SystemUtils.java

public static void PrintMemoryUsage(String memMesg) {
    StringBuffer sb = new StringBuffer();
    double availableMem;
    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(true);//from   ww  w  . j  a v  a2s. c  om
    nf.setMaximumFractionDigits(3);

    availableMem = GetAvailableMemory();

    sb.append(memMesg);

    sb.append(nf.format(availableMem));
    sb.append(" MB");

    System.out.println(sb.toString());
}

From source file:org.createnet.raptor.models.data.types.NumberRecord.java

@Override
public Number parseValue(Object value) {
    try {/*from www . j a  va 2  s .  c  o m*/

        if (value instanceof Number) {
            return (Number) value;
        }

        if (value instanceof JsonNode) {

            JsonNode node = (JsonNode) value;

            if (node.isNumber()) {

                if (node.isInt() || node.isShort()) {
                    return (Number) node.asInt();
                }

                if (node.isDouble() || node.isFloat()) {
                    return (Number) node.asDouble();
                }

                if (node.isLong()) {
                    return (Number) node.asLong();
                }
            }

            if (node.isTextual()) {
                value = node.asText();
            }

        }

        NumberFormat formatter = NumberFormat.getInstance();
        ParsePosition pos = new ParsePosition(0);
        Number numVal = formatter.parse((String) value, pos);

        return numVal;
    } catch (Exception e) {
        throw new RaptorComponent.ParserException(e);
    }
}

From source file:com.alibaba.json.test.Bug_0_Test.java

private void f_ali_json() {
    long startNano = System.nanoTime();
    for (int i = 0; i < COUNT; ++i) {
        com.alibaba.fastjson.JSON.parse(text);
    }/*from   w w  w.ja va2 s. c  om*/
    long nano = System.nanoTime() - startNano;
    System.out.println(NumberFormat.getInstance().format(nano));
}

From source file:com.anrisoftware.globalpom.format.point.PointFormat.java

/**
 * Uses the default decimal format to format the X and Y coordinates of a
 * point.//  ww  w.j  a v  a 2  s .  co  m
 * 
 * @param logger
 *            the {@link PointFormatLogger} for logging messages.
 */
@AssistedInject
PointFormat(PointFormatLogger logger) {
    this(logger, NumberFormat.getInstance());
}

From source file:com.newatlanta.bluedragon.CategoryItemLabelGenerator.java

/**
 * Creates a new generator with a default number formatter.
 */
public CategoryItemLabelGenerator() {
    super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance());
}