code: public static <M extends MessageOrBuilder> M updateTimestamp(final long time, final M messageOrBuilder, final TimeUnit timeUnit) throws CouldNotPerformException {
          long milliseconds = TimeUnit.MILLISECONDS.convert(time, timeUnit);
  
          try {
  
              if (messageOrBuilder == null) {
                  throw new NotAvailableException("messageOrBuilder");
              }
  
              try {
                  // handle builder
                  if (messageOrBuilder.getClass().getSimpleName().equals("Builder")) {
                      messageOrBuilder.getClass().getMethod(SET + TIMESTAMP_NAME, Timestamp.class).invoke(messageOrBuilder, TimestampJavaTimeTransform.transform(milliseconds));
                      return messageOrBuilder;
                  }
  
                  //handle message
                  final Object builder = messageOrBuilder.getClass().getMethod("toBuilder").invoke(messageOrBuilder);
                  builder.getClass().getMethod(SET + TIMESTAMP_NAME, Timestamp.class).invoke(builder, TimestampJavaTimeTransform.transform(milliseconds));
                  return (M) builder.getClass().getMethod("build").invoke(builder);
              } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException ex) {
                  throw new NotSupportedException("Field[Timestamp]", messageOrBuilder.getClass().getName(), ex);
              }
          } catch (CouldNotPerformException ex) {
              throw new CouldNotPerformException("Could not update timestemp! ", ex);
          }
      }
docs: Method updates the timestamp field of the given message with the given time in the given timeUnit.
  
  @param <M>              the message type of the message which is updated
  @param time             the time which is put in the timestamp field
  @param messageOrBuilder the message
  @param timeUnit         the unit of time
  
  @return the updated message
  
  @throws CouldNotPerformException is thrown in case the copy could not be performed e.g. because of a missing timestamp field.