Java Number Format Pattern formatThousands(String inValue)

Here you can find the source of formatThousands(String inValue)

Description

format Thousands

License

Open Source License

Declaration

public static String formatThousands(String inValue) 

Method Source Code


//package com.java2s;
/*//from   w w  w .  j  av a  2s  . co m
 * Copyright (c) 2013, 2014 Chris Newland.
 * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
 * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
 */

import java.text.DecimalFormat;

public class Main {
    private static final DecimalFormat DF_THOUSANDS = new DecimalFormat("#,###");

    public static String formatThousands(String inValue) {
        String value = inValue;
        // see if it can be formatted as a long with commas at thousands
        try {
            value = DF_THOUSANDS.format(Long.parseLong(value));
        } catch (NumberFormatException nfe) {
        }

        return value;
    }
}

Related

  1. formatNumber(Number number)
  2. FormatNumber(Object o,String patter)
  3. formatoDecimalPunto(String numero)
  4. formatQuantity(Long quantity)
  5. formattedDuration(long pStartTime)
  6. formatTime(long endTime, long startTime)
  7. formatTokens(long tokens)
  8. formatValue(int value)
  9. formatValue(Object value)