Java Hex to Int convertHexToDec(String in)

Here you can find the source of convertHexToDec(String in)

Description

convert Hex To Dec

License

Open Source License

Declaration

public static String convertHexToDec(String in) 

Method Source Code

//package com.java2s;
/*//  w  w w.  ja  va2  s .  c  o m
 * M2M ServiceFOTA ONM version 1.0
 *
 *  Copyright ? 2014 kt corp. All rights reserved.
 *
 *  This is a proprietary software of kt corp, and you may not use this file except in
 *  compliance with license agreement with kt corp. Any redistribution or use of this
 *  software, with or without modification shall be strictly prohibited without prior written
 *  approval of kt corp, and the copyright notice above does not evidence any actual or
 *  intended publication of such software.
 */

public class Main {

    public static String convertHexToDec(String in) {
        if (in == null) {
            return null;
        } else {
            if (in.equals("**"))
                return "*";

            int hex = Integer.parseInt(in, 16);
            return String.valueOf(Integer.toString(hex));
        }
    }

    public static boolean equals(String source, String target) {

        return checkNull(source).equals(checkNull(target));

    }

    public static String checkNull(String str) {
        return checkNull(str, "");
    }

    public static String checkNull(String str, String def) {
        if (isEmpty(str)) {
            str = def;
        }

        return str;
    }

    public static String checkNull(Object object) {
        String string = "";
        if (object != null) {
            string = object.toString().trim();
        }
        return string;
    }

    public static boolean isEmpty(String str) {

        if (str != null) {
            str = str.trim();
        }

        return (str == null || str.length() == 0);
    }

    public static String trim(String origString, String trimString) {
        int startPosit = origString.indexOf(trimString);
        if (startPosit != -1) {
            int endPosit = trimString.length() + startPosit;
            return origString.substring(0, startPosit) + origString.substring(endPosit);
        }
        return origString;
    }
}

Related

  1. convertHexBytesToInt(byte[] hex)
  2. convertHexDigitAsInt(char c)
  3. convertHexStringToInt(String hex)
  4. convertHexStringToInt(String hexString)
  5. convertHexToInt(String hex)
  6. hexChar2dec(char hex)
  7. hexChar2Int(char ch)