سؤال

How to determine whether current month is a summer or winter from GMT date.

Suppose we are in may, how to determine if may is a summer month or winter month for the current year.

DateTimeZone franceZone = DateTimeZone.ForId("Europe/France");

DateTimeZone localZone = DateTimeZone.SystemDefault;
ZonedDateTime utc = new ZonedDateTime(2014, 05, 15, 9, 0, 0, DateTimeZone.CEST);
ZonedDateTime france = new ZonedDateTime(CEST.ToInstant(), franceZone);
Console.WriteLine(france.LocalDateTime);
هل كانت مفيدة؟

المحلول

Create two arrayslists
1- Summer months 2- Winter months

When you retrieve the month value from GMT date run a check through the arraylist to see which array the value matches.

for (String s : arrayList)
    if (s.equals(value)){
 season= winter
}

Maybe something like that pseudo code

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top