I need to get Joda's DateTime
object which will represent next (nearest) 8 AM of Moscow time. I.e. if now 7 AM of Moscow time, then I want to get 8 AM of the same day (which will happen in 1 hour), and if current time is more than 8 AM of Moscow time (for example 3 PM or 15:00), then I need to get 8 AM (8:00) of next day.
Is there some simple built-in method to do it?
For now I think I will do it using this code/pseudocode:
// get current moment in default time zone
DateTime dt = new DateTime();
// translate to Moscow local time
DateTime dtMoscow = dt.withZone(DateTimeZone.forID("Europe/Moscow"));
if (dtMoscow.getHourOfDay >= 8) {
dtMoscow = dtMoscow.plusDays(1)
}
DateTime result = dtMoscow.withHourOfDay(8).withMinuteOfHour(0).withSecondOfMinute(0)