PackedLocalTime { public static int plusMinutes(int minutesToAdd, int packedTime) { if (minutesToAdd == 0) { return packedTime; } int hour = PackedLocalTime.getHour(packedTime); int minute = PackedLocalTime.getMinute(packedTime); int second = PackedLocalTime.getSecond(packedTime); int milli = PackedLocalTime.getMilliseconds(packedTime); int mofd = hour * MINUTES_PER_HOUR + minute; int newMofd = ((minutesToAdd % MINUTES_PER_DAY) + mofd + MINUTES_PER_DAY) % MINUTES_PER_DAY; if (mofd == newMofd) { return packedTime; } int newHour = newMofd / MINUTES_PER_HOUR; int newMinute = newMofd % MINUTES_PER_HOUR; return create(newHour, newMinute, second, milli); }  static byte getHour(int time); static int of(int hour, int minute); static int of(int hour, int minute, int second); static int of(int hour, int minute, int second, int millis); static int truncatedTo(TemporalUnit unit, int packedTime); static int plusHours(int hoursToAdd, int packedTime); static int plusMinutes(int minutesToAdd, int packedTime); static int plusSeconds(int secondsToAdd, int packedTime); static int plusMilliseconds(int msToAdd, int packedTime); static int minusHours(int hoursToSubtract, int packedTime); static int minusMinutes(int minutesToSubtract, int packedTime); static int minusSeconds(int secondsToSubtract, int packedTime); static int minusMilliseconds(int millisToSubtract, int packedTime); static int withHour(int hour, int packedTime); static int withMinute(int minute, int packedTime); static int withSecond(int second, int packedTime); static int withMillisecond(int milliseconds, int packedTime); static char getMillisecondOfMinute(int time); static int getNano(int time); static int getMilliseconds(int time); static long toNanoOfDay(int time); static LocalTime asLocalTime(int time); static byte getMinute(int time); static int pack(LocalTime time); static byte getSecond(int packedLocalTime); static int getMinuteOfDay(int packedLocalTime); static int getSecondOfDay(int packedLocalTime); static int getMillisecondOfDay(int packedLocalTime); static String toShortTimeString(int time); static boolean isMidnight(int packedTime); static boolean isNoon(int packedTime); static boolean isAfter(int packedTime, int otherPackedTime); static boolean isOnOrAfter(int packedTime, int otherPackedTime); static boolean isBefore(int packedTime, int otherPackedTime); static boolean isOnOrBefore(int packedTime, int otherPackedTime); static boolean isEqualTo(int packedTime, int otherPackedTime); static boolean AM(int packedTime); static boolean PM(int packedTime); static int hoursUntil(int packedTimeEnd, int packedTimeStart); static int minutesUntil(int packedTimeEnd, int packedTimeStart); static int secondsUntil(int packedTimeEnd, int packedTimeStart);  }
@Test public void testPlusMinutes() { LocalTime localTime = LocalTime.of(5, 11, 33, 811 * 1_000_000); LocalTime localTime2 = localTime.plusMinutes(77); int packedTime = pack(localTime); int packedTime2 = plusMinutes(77, packedTime); assertTimeEquals(localTime2, packedTime2); int packedTime3 = minusMinutes(77, packedTime2); assertTimeEquals(localTime, packedTime3); }