class PackedLocalTime {

  public static int withSecond(int second, int packedTime) {
    if (PackedLocalTime.getSecond(packedTime) == second) {
      return packedTime;
    }
    ChronoField.SECOND_OF_MINUTE.checkValidValue(second);
    return create(
        PackedLocalTime.getHour(packedTime),
        PackedLocalTime.getMinute(packedTime),
        second,
        PackedLocalTime.getMilliseconds(packedTime));
  }

}