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