Skip to content
Sharp

API Evolution · interview question

How would you create a ZonedDateTime for the current moment in the 'America/New_York' timezone?

Multiple choiceHardchapter-12-curatedpremiumapi-evolutionmodern-date-and-time
Choose one answer
Answer and explanation

Correct answer

A. ZonedDateTime.now(ZoneId.of('America/New_York'))

Why

To create a ZonedDateTime for the current moment in a specific timezone, use ZonedDateTime.now(ZoneId.of('America/New_York')). This ensures the datetime is correctly aligned with the local time in the specified timezone.

Test yourself on API Evolution

A free test with instant, explained results. No account needed.

Start free test
All API Evolution questions →