### Question:
SystemTimeEncoder { public byte[] toByteArray(ASSystemTime toEncode) { byte[] year = toEncode.getYear().toByteArray(); byte[] month = toEncode.getMonth().toByteArray(); byte[] dayOfWeek = toEncode.getDayOfWeek().toByteArray(); byte[] day = toEncode.getWeekOfMonth().toByteArray(); byte[] hour = toEncode.getHour().toByteArray(); byte[] minute = toEncode.getMinute().toByteArray(); byte[] second = toEncode.getSecond().toByteArray(); byte[] millis = toEncode.getMilliseconds().toByteArray(); return Bytes.concat(year, month, dayOfWeek, day, hour, minute, second, millis); } @Inject @VisibleForTesting  SystemTimeEncoder(); byte[] toByteArray(ASSystemTime toEncode); ASSystemTime toASSystemTime(byte[] toEncode);  }### Answer:
@Test public void testEncodeTimeZeroDate() { ASSystemTime systemTime = new ASSystemTime.FromDateBuilder().dateTime(new DateTime(0)).build(); byte[] asBinary = systemTimeEncoder.toByteArray(systemTime); byte[] year = byteArrayOfUnsignedShort(0); byte[] month = byteArrayOfUnsignedShort(0); byte[] dayOfWeek = byteArrayOfUnsignedShort(0); byte[] weekOfMonth = byteArrayOfUnsignedShort(0); byte[] hour = byteArrayOfUnsignedShort(0); byte[] minute = byteArrayOfUnsignedShort(0); byte[] second = byteArrayOfUnsignedShort(0); byte[] millis = byteArrayOfUnsignedShort(0); byte[] expectedBinary = Bytes.concat(year, month, dayOfWeek, weekOfMonth, hour, minute, second, millis); assertThat(asBinary).isEqualTo(expectedBinary); }
@Test public void testEncodeLastMillisOf2012Date() { ASSystemTime systemTime = new ASSystemTime.FromDateBuilder() .dateTime(new DateTime(DateTime.parse("2012-12-31T23:59:59.999+00"), DateTimeZone.UTC)).build(); byte[] asBinary = systemTimeEncoder.toByteArray(systemTime); byte[] year = byteArrayOfUnsignedShort(2012); byte[] month = byteArrayOfUnsignedShort(12); byte[] dayOfWeek = byteArrayOfUnsignedShort(1); byte[] weekOfMonth = byteArrayOfUnsignedShort(5); byte[] hour = byteArrayOfUnsignedShort(23); byte[] minute = byteArrayOfUnsignedShort(59); byte[] second = byteArrayOfUnsignedShort(59); byte[] millis = byteArrayOfUnsignedShort(999); byte[] expectedBinary = Bytes.concat(year, month, dayOfWeek, weekOfMonth, hour, minute, second, millis); assertThat(asBinary).isEqualTo(expectedBinary); }
@Test public void testEncodeFirstMillisOf2015Date() { ASSystemTime systemTime = new ASSystemTime.FromDateBuilder() .dateTime(new DateTime(DateTime.parse("2015-01-01T00:00:00.000+00"), DateTimeZone.UTC)).build(); byte[] asBinary = systemTimeEncoder.toByteArray(systemTime); byte[] year = byteArrayOfUnsignedShort(2015); byte[] month = byteArrayOfUnsignedShort(1); byte[] dayOfWeek = byteArrayOfUnsignedShort(4); byte[] weekOfMonth = byteArrayOfUnsignedShort(1); byte[] hour = byteArrayOfUnsignedShort(0); byte[] minute = byteArrayOfUnsignedShort(0); byte[] second = byteArrayOfUnsignedShort(0); byte[] millis = byteArrayOfUnsignedShort(0); byte[] expectedBinary = Bytes.concat(year, month, dayOfWeek, weekOfMonth, hour, minute, second, millis); assertThat(asBinary).isEqualTo(expectedBinary); }