Convert hex to char - Android java.lang

Android examples for java.lang:Character

Description

Convert hex to char

Demo Code


//package com.java2s;

public class Main {
    public static int hex2int(char c) {
        if (c >= '0' && c <= '9') {
            return (c - '0') * 16;
        }//from www.jav  a  2 s .c o m
        if (c >= 'A' && c <= 'F') {
            return (c - 'A' + 10) * 16;
        }
        return 0;
    }
}

Related Tutorials