Class DataTypeConversionFunctions


  • public class DataTypeConversionFunctions
    extends Object
    Contains function to convert a datatype to another datatype.
    • Method Detail

      • bigDecimalToBytes

        public static byte[] bigDecimalToBytes​(BigDecimal bigDecimal)
        Converts BigDecimal to bytes. Only scale of upto 2 bytes is supported by the function
        Parameters:
        bigDecimal - big decimal number
        Returns:
        The result byte array contains the bytes of the unscaled value appended to bytes of the scale in BIG ENDIAN order.
      • bytesToBigDecimal

        public static BigDecimal bytesToBigDecimal​(byte[] bytes)
        Converts serialized BigDecimal bytes to value.
        Parameters:
        bytes - array that contains the bytes of the unscaled value appended to 2 bytes of the scale in BIG ENDIAN order.
        Returns:
        big decimal number
      • hexToBytes

        public static byte[] hexToBytes​(String hex)
        convert simple hex string to byte array
        Parameters:
        hex - a plain hex string e.g. 'f0e1a3b2'
        Returns:
        byte array representation of hex string
      • bytesToHex

        public static String bytesToHex​(byte[] bytes)
        convert simple bytes array to hex string
        Parameters:
        bytes - any byte array
        Returns:
        plain hex string e.g. 'f012be3c'
      • base64Encode

        public static byte[] base64Encode​(byte[] input)
        Encodes bytes using Base64.
        Parameters:
        input - original bytes
        Returns:
        base64 encoded bytes
      • base64Decode

        public static byte[] base64Decode​(byte[] input)
        Decodes Base64 encoded bytes.
        Parameters:
        input - base64 encoded bytes
        Returns:
        decoded bytes