As I understand your requirements
- Image upload happens every day between 8:45 and 9 AM in the uploader’s (your) time zone. Download is possible at all other times.
- Each client should display the image from the previous day every day at 9 AM in the client’s time zone.
- The client should be allowed a window of 23 h 45 min for downloading the image.
I also understand that it works nicely with clients in your own time zone.
Let’s look at the example from your comment to another answer: Upload happens from Asia/Kolkata time zone (India), and there is a client in Asia/Tokyo time zone (Japan). When the upload is finished at 9 in India, the time is already 12:30 in Japan. There are websites that will make such time zone conversions for you, for example Time Zone Converter – Time Difference Calculator. At 12:30 in Japan there are only 20 h 30 min left until the image should be displayed at 9 the next morning. So we cannot fulfil the requirements.
Let’s for a moment imagine that you settle with a 20 h 30 window (which you may not want to). For the client to find out when and how long that window is, it just needs to know the uploader’s time zone. It then converts 9:00 Asia/Kolkata to 12:30 Asia/Tokyo to discover that the window opens at 12:30. How to do the conversion in the client program, you can find that in other questions and answers, for example Timezone conversion.
If the client in Tokyo needs a 23 h 45 window, you will need to upload the image earlier. More precisely, it needs to be uploaded no later than 9:15 Japanese time. Again, convert this time to your own time zone to find out when that is.
We’re not done yet. While Japanese time (UTC+9) is ahead of Indian time, some time zones are even further ahead. According to Time Zone Abbreviations – Worldwide List some time zones are at UTC+14, either all year or in summer. And the list isn’t static. To prepare for future changes, you may want to add another couple of hours. Zone offsets in java.time
go to UTC+18.
If you upload your image before 9:15 at, say, UTC+16, you are creating a challenge for clients in your own time zone and other time zones that are not that far ahead. Clients may be able to cope with the challenge if they know when the upload happens. It just means that very often they will have to save more pictures for the days to come, and they will need to convert the upload time to their own time zone. A more practical way to handle the latter is probably to announce and handle upload time in UTC, as Abdul Waheed said in another answer.
ThreeTenABP
For your time zone conversions I recommend JSR-310, the modern Java date and time API also known as java.time
. This is not built-in on most Android devices yet (it will come), so you need the ThreeTenABP, the backport of JSR-310 to Android. There is a thorough explanation in this question: How to use ThreeTenABP in Android Project. Then you may for instance code your time zone conversion using this answer.
To learn more about the modern API, visit the Oracle tutorial or find other resources on the net.