class PackedLocalTime {

  public static int withHour(int hour, int packedTime) {
    if (PackedLocalTime.getHour(packedTime) == hour) {
      return packedTime;
    }
    ChronoField.HOUR_OF_DAY.checkValidValue(hour);
    return create(
        hour,
        PackedLocalTime.getMinute(packedTime),
        PackedLocalTime.getSecond(packedTime),
        PackedLocalTime.getMilliseconds(packedTime));
  }

}