Java Number to String numberToString(Object num)

Here you can find the source of numberToString(Object num)

Description

number To String

License

Open Source License

Declaration

public static String numberToString(Object num) 

Method Source Code

//package com.java2s;

public class Main {

    public static String numberToString(Object num) {
        if (num == null) {
            return null;
        } else if (num instanceof Integer && (Integer) num > 0) {
            return Integer.toString((Integer) num);
        } else if (num instanceof Long && (Long) num > 0) {
            return Long.toString((Long) num);
        } else if (num instanceof Float && (Float) num > 0) {
            return Float.toString((Float) num);
        } else if (num instanceof Double && (Double) num > 0) {
            return Double.toString((Double) num);
        } else {/*from  ww  w  .j a  va2s.  c  o m*/
            return "";
        }
    }
}

Related

  1. numberToString(double num, int digits)
  2. numberToString(int gmNumber)
  3. numberToString(int number, int length, String type, int location)
  4. numberToString(Number number)
  5. numberToString(Object instance)
  6. numberToStringFlushLeft(long number, int width)