BluetoothBytesParser { public Date getDateTime() { Date result = getDateTime(offset); offset += 7; return result; } BluetoothBytesParser();  BluetoothBytesParser(ByteOrder byteOrder);  BluetoothBytesParser(byte[] value);  BluetoothBytesParser(byte[] value, ByteOrder byteOrder);  BluetoothBytesParser(byte[] value, int offset);  BluetoothBytesParser(byte[] value, int offset, ByteOrder byteOrder); Integer getIntValue(int formatType); Integer getIntValue(int formatType, ByteOrder byteOrder); long getLongValue(); long getLongValue(ByteOrder byteOrder); long getLongValue(int offset, ByteOrder byteOrder); Integer getIntValue(int formatType, int offset, ByteOrder byteOrder); Float getFloatValue(int formatType); Float getFloatValue(int formatType, ByteOrder byteOrder); Float getFloatValue(int formatType, int offset, ByteOrder byteOrder); String getStringValue(); String getStringValue(int offset); Date getDateTime(); Date getDateTime(int offset); byte[] getValue(); boolean setIntValue(int value, int formatType, int offset); boolean setIntValue(int value, int formatType); boolean setLong(long value); boolean setLong(long value, int offset); boolean setFloatValue(int mantissa, int exponent, int formatType, int offset); boolean setFloatValue(float value, int precision); boolean setString(String value); boolean setString(String value, int offset); void setValue(byte[] value); boolean setCurrentTime(Calendar calendar); boolean setDateTime(Calendar calendar); static String bytes2String(final byte[] bytes); static byte[] mergeArrays(byte[]... arrays); int getOffset(); void setOffset(int offset); ByteOrder getByteOrder(); @Override String toString(); static final int FORMAT_UINT8; static final int FORMAT_UINT16; static final int FORMAT_UINT32; static final int FORMAT_SINT8; static final int FORMAT_SINT16; static final int FORMAT_SINT32; static final int FORMAT_SFLOAT; static final int FORMAT_FLOAT; }
@Test public void parseDateTimeTest() { BluetoothBytesParser parser = new BluetoothBytesParser(new byte[]{(byte)0xE4, 0x07, 0x01, 0x02, 0x0a, 0x15, 0x30}); Date dateTime = parser.getDateTime(); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(dateTime); assertEquals(2020, calendar.get(GregorianCalendar.YEAR)); assertEquals(1, calendar.get(GregorianCalendar.MONTH) + 1); assertEquals(2, calendar.get(GregorianCalendar.DAY_OF_MONTH)); assertEquals(10, calendar.get(GregorianCalendar.HOUR_OF_DAY)); assertEquals(21, calendar.get(GregorianCalendar.MINUTE)); assertEquals(48, calendar.get(GregorianCalendar.SECOND)); }