I need to use a date in a URL, therefore the date cannot contain any symbols like hyphen -
, dash /
or colon :
.
I think 20220615T160543Z
is the only suitable format, but the issue is that it is in UTC, but I need it in some other time zone.
Is there anything like 20220615T160543+2:00
, where the +2:00
part indicates the time zone offset from UTC?
If yes, can I print it out of a ZonedDateTime
object?
The object I currently have is
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(date.getStartsOn().toInstant(), timezone);
Thanks in advance!
Update:
Thanks for all the responses!
It looks like my suggested approach is not doable, because it could be like 20220615T160543-2:00
where there is a hyphen...
Apparently percentage-encoding is the only way to do it.
Thanks again!