Here you can find the source of getPossibleUserTimezoneList(int userOffsetInHours)
Parameter | Description |
---|---|
hoursOffset | a parameter |
public static ArrayList getPossibleUserTimezoneList(int userOffsetInHours)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.TimeZone; public class Main { /**//from w w w . ja va 2s .co m * Add possible client list from it's current GMT offset in hours * We add the xones for the current offest and also the ones for offset-1 and offset+1 because * we have no way to know (or at leats that i know of) wether the client is currently in Daylight savings or not * by adding the 1hour before and after timezones this should cover the potential offsets at those times of the year * where the client is in DST but GMT is not yet. * Ex: client in the US during late march is -7 vs GMT(not swicthed to summer time yet) rather than usual -8. * @param hoursOffset * @return */ public static ArrayList getPossibleUserTimezoneList(int userOffsetInHours) { ArrayList list = new ArrayList(); String[] s1 = TimeZone.getAvailableIDs(userOffsetInHours * 3600000); for (int i = 0; i != s1.length; i++) { list.add(s1[i]); } s1 = TimeZone.getAvailableIDs((userOffsetInHours - 1) * 3600000); for (int i = 0; i != s1.length; i++) { list.add(s1[i]); } s1 = TimeZone.getAvailableIDs((userOffsetInHours + 1) * 3600000); for (int i = 0; i != s1.length; i++) { list.add(s1[i]); } return list; } }