Java Number Format format(String number)

Here you can find the source of format(String number)

Description

format

License

Open Source License

Declaration

public static String format(String number) 

Method Source Code

//package com.java2s;
/*******************************************************************************
* Copyright (c) 2010-2016 ITER Organization.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/

public class Main {
    public static String format(String number) {
        StringBuilder cleanedNumber = new StringBuilder();
        for (int index = 0; index < number.length(); index++) {
            char c = number.charAt(index);
            if (c == '+' || c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6'
                    || c == '7' || c == '8' || c == '9')
                cleanedNumber.append(c);
        }/*  ww w .j a va 2  s .c  o  m*/
        return cleanedNumber.toString();
    }
}

Related

  1. format(int decs, double number)
  2. format(int number, int length)
  3. format(Number number)
  4. format(String number)
  5. formatAmountDigits(String numberString, int length)
  6. formatBinaryNumber(int number, int size)
  7. formatBytes(long number)
  8. formatBytesHumanReadable(float number)