Class DataTypeConversionFunctions


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

      • bigDecimalToBytes

        public static byte[] bigDecimalToBytes​(String number)
        Converts big decimal string representation to bytes. Only scale of upto 2 bytes is supported by the function
        Parameters:
        number - big decimal number in plain string. e.g. '1234.12121'
        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 String bytesToBigDecimal​(byte[] bytes)
        Converts bytes value representation generated by bigDecimalToBytes(String) back to string big decimal
        Parameters:
        bytes - array that contains the bytes of the unscaled value appended to 2 bytes of the scale in BIG ENDIAN order.
        Returns:
        plain string representation of big decimal
      • 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)
        encode byte array to base64 using Base64
        Parameters:
        input - original byte array
        Returns:
        base64 encoded byte array
      • base64Decode

        public static byte[] base64Decode​(String input)
        decode base64 encoded string to bytes using Base64
        Parameters:
        input - base64 encoded string
        Returns:
        decoded byte array