@Test public void exactTime256WithUpdateReason_millennium() { assertArrayEquals( new byte[]{-48, 7, 1, 1, 0, 0, 0, 6, 0, 0}, TimeData.exactTime256WithUpdateReason(utc("00:00:00 01 Jan 2000"), TimeData.UPDATE_REASON_UNKNOWN) ); }
static byte[] exactTime256WithUpdateReason(Calendar time, byte updateReason) { int month = time.get(Calendar.MONTH) + 1; int dayOfWeek = time.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SUNDAY) { dayOfWeek = 7; } else { dayOfWeek = dayOfWeek - 1; } int fractionsOfSecond = (int)((time).get(Calendar.MILLISECOND) * 0.255F); return ByteBuffer.allocate(10) .order(ByteOrder.LITTLE_ENDIAN) .putShort((short) time.get(Calendar.YEAR)) .put((byte) month) .put((byte) time.get(Calendar.DAY_OF_MONTH)) .put((byte) time.get(Calendar.HOUR_OF_DAY)) .put((byte) time.get(Calendar.MINUTE)) .put((byte) time.get(Calendar.SECOND)) .put((byte) dayOfWeek) .put((byte) fractionsOfSecond) .put(updateReason) .array(); }
TimeData { static byte[] exactTime256WithUpdateReason(Calendar time, byte updateReason) { int month = time.get(Calendar.MONTH) + 1; int dayOfWeek = time.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SUNDAY) { dayOfWeek = 7; } else { dayOfWeek = dayOfWeek - 1; } int fractionsOfSecond = (int)((time).get(Calendar.MILLISECOND) * 0.255F); return ByteBuffer.allocate(10) .order(ByteOrder.LITTLE_ENDIAN) .putShort((short) time.get(Calendar.YEAR)) .put((byte) month) .put((byte) time.get(Calendar.DAY_OF_MONTH)) .put((byte) time.get(Calendar.HOUR_OF_DAY)) .put((byte) time.get(Calendar.MINUTE)) .put((byte) time.get(Calendar.SECOND)) .put((byte) dayOfWeek) .put((byte) fractionsOfSecond) .put(updateReason) .array(); } }
TimeData { static byte[] exactTime256WithUpdateReason(Calendar time, byte updateReason) { int month = time.get(Calendar.MONTH) + 1; int dayOfWeek = time.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SUNDAY) { dayOfWeek = 7; } else { dayOfWeek = dayOfWeek - 1; } int fractionsOfSecond = (int)((time).get(Calendar.MILLISECOND) * 0.255F); return ByteBuffer.allocate(10) .order(ByteOrder.LITTLE_ENDIAN) .putShort((short) time.get(Calendar.YEAR)) .put((byte) month) .put((byte) time.get(Calendar.DAY_OF_MONTH)) .put((byte) time.get(Calendar.HOUR_OF_DAY)) .put((byte) time.get(Calendar.MINUTE)) .put((byte) time.get(Calendar.SECOND)) .put((byte) dayOfWeek) .put((byte) fractionsOfSecond) .put(updateReason) .array(); } private  TimeData(); }
TimeData { static byte[] exactTime256WithUpdateReason(Calendar time, byte updateReason) { int month = time.get(Calendar.MONTH) + 1; int dayOfWeek = time.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SUNDAY) { dayOfWeek = 7; } else { dayOfWeek = dayOfWeek - 1; } int fractionsOfSecond = (int)((time).get(Calendar.MILLISECOND) * 0.255F); return ByteBuffer.allocate(10) .order(ByteOrder.LITTLE_ENDIAN) .putShort((short) time.get(Calendar.YEAR)) .put((byte) month) .put((byte) time.get(Calendar.DAY_OF_MONTH)) .put((byte) time.get(Calendar.HOUR_OF_DAY)) .put((byte) time.get(Calendar.MINUTE)) .put((byte) time.get(Calendar.SECOND)) .put((byte) dayOfWeek) .put((byte) fractionsOfSecond) .put(updateReason) .array(); } private  TimeData();  }
TimeData { static byte[] exactTime256WithUpdateReason(Calendar time, byte updateReason) { int month = time.get(Calendar.MONTH) + 1; int dayOfWeek = time.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SUNDAY) { dayOfWeek = 7; } else { dayOfWeek = dayOfWeek - 1; } int fractionsOfSecond = (int)((time).get(Calendar.MILLISECOND) * 0.255F); return ByteBuffer.allocate(10) .order(ByteOrder.LITTLE_ENDIAN) .putShort((short) time.get(Calendar.YEAR)) .put((byte) month) .put((byte) time.get(Calendar.DAY_OF_MONTH)) .put((byte) time.get(Calendar.HOUR_OF_DAY)) .put((byte) time.get(Calendar.MINUTE)) .put((byte) time.get(Calendar.SECOND)) .put((byte) dayOfWeek) .put((byte) fractionsOfSecond) .put(updateReason) .array(); } private  TimeData();   }