I have tried to get the current Instance on a specific timeZone but it does not work as expected. Any idea on how to do this ?
Here is what i did:
I
Instant
are not Timezone aware. If you need a time zone aware timestamp, you should use ZonedDateTime
.
Check out ZonedDateTime.now(timezone) which will use the provided timezone. To use the machine's default timezone, use ZonedDateTime.now()
If you want to parse a ZonedDateTime and override the timezone, you can use ZonedDateTime.withZoneSameLocal or ZonedDateTime.withZoneSameInstant depending on your need.