I have the following simple code to get the Day of week according to a timezone.
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(details.getTimezone()));
String dayOfWeek = new SimpleDateFormat("EEEE").format(calendar.get(Calendar.DAY_OF_WEEK));
Here, the details.getTimezone()
returns an acceptable value such as "Asia/Kolkata" and the calendar.get(Calendar.DAY_OF_WEEK)
returns the correct value 6.
According to the sequence, day 6 should return "Friday", but this function returns "Thursday" instead.
Please let me know if I am doing anything wrong.
Also let me know if I'm correct in understanding that DAY_OF_WEEK = 6 means Friday.