title: Convert zoned timestamp to com.google.protobuf.Timestamp
body: <p>In my custom API that I am creating using Swagger, I need to input a timestamp.</p>
  <p>In my YAML file I have defined the format of my input parameter as <code>date-time</code> as mentioned on the Swagger webpage <a href="https://swagger.io/docs/specification/data-models/data-types/#string" rel="nofollow noreferrer">date-time – the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z</a></p>
  <p>I want to convert the resulting zoned timestamp to <code>com.google.protobuf.Timestamp</code> but I don´t know how to do that and need help. I am using Kotlin.</p>
  <p>So far I´ve tried implementing some of the Java examples from StackOverflow (after converting to Kotlin), for instance:</p>
  <pre><code>System.out.println(new SimpleDateFormat(&quot;yyyy-MM-dd'T'HH:mm:ssXXX&quot;)
          .format(new Date()));
  </code></pre>
  <p>and</p>
  <pre><code>LocalDateTime withoutTimezone = zoneDateTime.toLocalDateTime();
  Timestamp timestamp = Timestamp.valueOf(withoutTimezone));
  </code></pre>
  <p>None of the examples seem to work since I need input parameter in <code>com.google.protobuf.Timestamp</code> format, which the above examples do not result in.</p>
  <p>Any help would be appreciated regarding how to convert timestamp.</p>