类 DataConvert


  • public class DataConvert
    extends Object
    作者:
    Yaqiang Wang
    • 构造器详细资料

      • DataConvert

        public DataConvert()
    • 方法详细资料

      • bytes2Float

        public static float bytes2Float​(byte[] b,
                                        ByteOrder byteOrder)
        Byte array convert to float
        参数:
        b - Byte array
        byteOrder - Byte order
        返回:
        Float value
      • bytes2Double

        public static double bytes2Double​(byte[] b,
                                          ByteOrder byteOrder)
        Byte array convert to double
        参数:
        b - Byte array
        byteOrder - Byte order
        返回:
        Double value
      • bytes2Int

        public static int bytes2Int​(byte[] bytes,
                                    ByteOrder byteOrder)
        Byte array convert to integer
        参数:
        bytes - Byte array
        byteOrder - Byte order
        返回:
        Integer value
      • bytes2Short

        public static short bytes2Short​(byte[] bytes,
                                        ByteOrder byteOrder)
        Byte array convert to short integer
        参数:
        bytes - Byte array
        byteOrder - Byte order
        返回:
        Short integer value
      • bytes2Short

        public static short bytes2Short​(byte[] bytes)
        Byte array convert to short integer
        参数:
        bytes - Byte array
        返回:
        Short integer value
      • bytes2UShort

        public static int bytes2UShort​(byte[] bytes)
        Byte array convert to unsigned short integer
        参数:
        bytes - Byte array
        返回:
        Unsigned short integer value
      • bytes2UShort

        public static int bytes2UShort​(byte[] bytes,
                                       ByteOrder byteOrder)
        Byte array convert to unsigned short integer
        参数:
        bytes - Byte array
        byteOrder - Byte order
        返回:
        Unsigned short integer value
      • bytes2Long

        public static Long bytes2Long​(byte[] bytes,
                                      ByteOrder byteOrder)
        Byte array convert to long integer
        参数:
        bytes - Byte array
        byteOrder - Byte order
        返回:
        Long integer value
      • bytes2Int

        public static int bytes2Int​(byte[] bytes)
        Byte array convert to integer
        参数:
        bytes - byte array
        返回:
        Integer value
      • bytes2Int2

        public static int bytes2Int2​(byte[] bytes)
        Byte array (2 bytes) convert to integer
        参数:
        bytes - byte array
        返回:
        Integer value
      • bytes2Int3

        public static int bytes2Int3​(byte[] bytes)
        Byte array (3 bytes) convert to integer
        参数:
        bytes - Byte array
        返回:
        Integer value
      • byte2Int

        public static int byte2Int​(byte b)
        Convert byte to int - byte in Java is signed
        参数:
        b - Input byte
        返回:
        Output integer
      • littleToBig

        public static byte[] littleToBig​(byte[] bytes)
        Convert LittleEndian to BigEndian
        参数:
        bytes - Input LittleEndian byte array
        返回:
        Output BigEndian byte array
      • bigToLittle

        public static byte[] bigToLittle​(byte[] bytes)
        Convert BigEndian to LittleEndian
        参数:
        bytes - Input BigEndian byte array
        返回:
        Output LittleEndian byte array
      • toBytes

        public static byte[] toBytes​(int i)
        Convert int to byte array.
        参数:
        i - Int value
        返回:
        Byte array
      • toUint3Int

        public static byte[] toUint3Int​(int i)
        Convert int to 3 byte array.
        参数:
        i - Int value
        返回:
        Byte array
      • toUint2Int

        public static byte[] toUint2Int​(int i)
        Convert int to 2 byte array.
        参数:
        i - Int value
        返回:
        Byte array
      • toUintNInt

        public static byte[] toUintNInt​(int i,
                                        int n)
        Convert int to N byte array.
        参数:
        i - Int value
        n - bit number
        返回:
        Byte array
      • toLittleBytes

        public static byte[] toLittleBytes​(int i)
        Convert int to byte array - LittleEndian
        参数:
        i - Int value
        返回:
        Byte array
      • toBytes

        public static byte[] toBytes​(float f)
        Convert float to byte array
        参数:
        f - Float value
        返回:
        Byte array
      • float2Bytes

        public static byte[] float2Bytes​(float f,
                                         ByteOrder byteOrder)
        Convert float to byte array
        参数:
        f - Float value
        byteOrder - ByteOrder
        返回:
        Byte array
      • toLittleBytes

        public static byte[] toLittleBytes​(float f)
        Convert float to byte array
        参数:
        f - Float array
        返回:
        Byte array
      • resizeArray

        public static Object resizeArray​(Object oldArray,
                                         int newSize)
        Resize array
        参数:
        oldArray - Old array
        newSize - New size
        返回:
        Resized array
      • resizeArray2D

        public static double[][] resizeArray2D​(double[][] oldArray,
                                               int newSize)
        Resize double 2d array
        参数:
        oldArray - Old array
        newSize - New size
        返回:
        Resized array
      • doubleToString

        public static String doubleToString​(double v)
        Double to string
        参数:
        v - The double value
        返回:
        Result string
      • removeTailingZeros

        public static String removeTailingZeros​(String s)
        Remove tail zero
        参数:
        s - The string
        返回:
        Result string
      • removeTail0

        public static String removeTail0​(String str)
        Remove last zero chars
        参数:
        str - String
        返回:
        Result string
      • toByte_bak1

        public static byte[] toByte_bak1​(BitSet bits)
      • toByteArray

        public static byte[] toByteArray​(BitSet bits)
      • toByteArray_bak

        public static byte[] toByteArray_bak​(BitSet bitSet)
      • getDateFormat

        public static String getDateFormat​(String format)
        Get date format string
        参数:
        format - Format string
        返回:
        Date format string
      • isDouble

        public static boolean isDouble​(String s)
        Check a string is double or not
        参数:
        s - The string
        返回:
        Boolean
      • isFloat

        public static boolean isFloat​(String s)
        Check a string is float or not
        参数:
        s - The string
        返回:
        Boolean
      • isInteger

        public static boolean isInteger​(String s)
        Check a string is integer or not
        参数:
        s - The string
        返回:
        Boolean
      • isBoolean

        public static boolean isBoolean​(String s)
        Check a string is boolean or not
        参数:
        s - The string
        返回:
        Boolean
      • isLocalDate

        public static boolean isLocalDate​(String s,
                                          DateTimeFormatter dateTimeFormatter)
        Check a string is local date or not
        参数:
        s - The string
        dateTimeFormatter - DateTimeFormatter
        返回:
      • isLocalTime

        public static boolean isLocalTime​(String s,
                                          DateTimeFormatter formatter)
        Check a string is local time or not
        参数:
        s - The string
        formatter - DateTimeFormatter
        返回:
      • isLocalDateTime

        public static boolean isLocalDateTime​(String s,
                                              DateTimeFormatter formatter)
        Check a string is local date time or not
        参数:
        s - The string
        formatter - DateTimeFormatter
        返回: