Java Integer Create toIntStr(String floatStr)

Here you can find the source of toIntStr(String floatStr)

Description

to Int Str

License

Open Source License

Declaration

public static String toIntStr(String floatStr) 

Method Source Code

//package com.java2s;

public class Main {

    public static String toIntStr(String floatStr) {
        if (floatStr == null || floatStr.length() < 1) {
            return "0";
        }/*from www.j  av a2s  .  co m*/
        int index = floatStr.indexOf(".");
        if (index == -1)
            return floatStr;
        if (index == 0)
            return "0";
        if (index == 1 && floatStr.substring(0, 1).equals("-")) {
            return "0";
        }
        String intStr = floatStr.substring(0, index);
        if (intStr.substring(0, 1).equals("-")) {
            long tmp = Long.parseLong(intStr) - 1;
            intStr = tmp + "";
        }
        return intStr;
    }
}

Related

  1. toInts(Integer[] values)
  2. toInts(long[] array)
  3. toInts(String intArray)
  4. toInts(String[] values)
  5. toIntsFromUBytes(byte[] byteArray)
  6. toIntString(Integer integer)
  7. toIntString(Object object)
  8. toIntUnsigned(short x)
  9. toIntValue(char ch)