Please read to the end‚ I will try to explain in detail.
I have one program‚ it only works for locals‚ in one country. Specifically, it is for one country but can be used for another. However, all hours, minutes and dates are adapted to one country. That’s why I think the program should run on the date of that country‚ the date of the program should be taken from the actual date in that country, not from the calendar on the phone.
User open app:
App show 21-November. (Date in that country)
Phone data 20-November. (In his home country, the date is still November 20)
(the app should display the exact date of that country et regardless of my phone calendar.)
Don’t you understand? Then leave your question as a comment‚ please help.
2
Answers
There are plenty of different ways to obtain it, this would be just two of them:
Your question is not clear, but it seems you want to represent a single moment as viewed in two different time zones.
Capture the current moment as seen in UTC (with an offset of zero hours-minutes-seconds).
Generally best to do your thinking, debugging, logging, storage, data-exchange, and most of your business logic in UTC. Adjust to a time zone mainly just for presentation to the user, and for particular business rules as required.
Adjust into one time zone.
Adjust to another time zone.
Our three objects, the
Instant
and the pair ofZonedDateTime
objects, all represent the very same moment, the same point on the timeline.For a particular moment, the date in Tokyo may be “tomorrow” while still “yesterday” in Edmonton.