Java SQL Date hexToBin(String sHexString)

Here you can find the source of hexToBin(String sHexString)

Description

This method is used to convert hexcidecimal to binary string

License

Open Source License

Parameter

Parameter Description
utilDate The Date in java.util.Date to java.sql.Date

Return

The data in java.sql.Date

Declaration

public static String hexToBin(String sHexString) 

Method Source Code

//package com.java2s;

public class Main {
    /**// www .jav a  2s .c  o m
     *  This method is used to convert hexcidecimal to binary string
     *
     *  @param utilDate The Date in java.util.Date to java.sql.Date
     *  @return         The data in java.sql.Date
     *  @exception      Exception
     */
    public static String hexToBin(String sHexString) {
        String sBinString = "";

        for (int i = 0; i < sHexString.length(); i++)
            sBinString += hexCharToBin(sHexString.charAt(i));
        return sBinString;
    }

    public static String hexCharToBin(char c) {
        String sBinStr = "";

        c = Character.toUpperCase(c);

        switch (c) {
        case '0':
            sBinStr = "0000";
            break;
        case '1':
            sBinStr = "0001";
            break;
        case '2':
            sBinStr = "0010";
            break;
        case '3':
            sBinStr = "0011";
            break;
        case '4':
            sBinStr = "0100";
            break;
        case '5':
            sBinStr = "0101";
            break;
        case '6':
            sBinStr = "0110";
            break;
        case '7':
            sBinStr = "0111";
            break;
        case '8':
            sBinStr = "1000";
            break;
        case '9':
            sBinStr = "1001";
            break;
        case 'A':
            sBinStr = "1010";
            break;
        case 'B':
            sBinStr = "1011";
            break;
        case 'C':
            sBinStr = "1100";
            break;
        case 'D':
            sBinStr = "1101";
            break;
        case 'E':
            sBinStr = "1110";
            break;
        case 'F':
            sBinStr = "1111";
            break;
        }
        return sBinStr;
    }
}

Related

  1. getProtobufClass(Object value, Class protobufClass)
  2. getTodayAndTomorrow()
  3. getWeekNumber()
  4. getWeekOfMonth(String year, String month, String day)
  5. getYearLater()
  6. isLastDayOfMonth(String theDataStr)
  7. isSimpleColumnType(Class columnType)
  8. isSimpleType(Object obj)
  9. issue20()