java - Getting current date and time based on the locale (country)

11,186

Since Java 8 you have LocalDateTime and ZonedDateTime

So you can do the same as @Babar said:

Get a zone id

ZoneId zoneId = ZoneId.of("Europe/Brussels");

And then get date and time

ZonedDateTime zonedDateTime = ZonedDateTime.now(zoneId);

Share:
11,186
Sriram
Author by

Sriram

Tech Enthusiastic, Java Developer by profession, Interested in new Apps/Gadgets, Android lover, More into Cloud, Passionate about music, And, Not single :P

Updated on June 04, 2022

Comments

  • Sriram
    Sriram almost 2 years

    I would like to fetch the current date / time based on the locale. If I pass locale object, I need to get the relevant date / time of the country.