The timezone mapper allows a likely timezone to be obtained for a given phone number. The timezone returned is the canonical ID from CLDR, not a localised name (or any other identifier). For mobile phones which are associated with particular area codes, it returns the timezone of the area code; it does not track the user's current location in any way. This could be used to work out whether it is likely to be a good time to ring a user based on their provided number.
Code Location: java/geocoder/src/com/google/i18n/phonenumbers/PhoneNumberToTimeZonesMapper.java
Example usage:
PhoneNumberToTimeZonesMapper timeZonesMapper = PhoneNumberToTimeZonesMapper.getInstance(); List<String> timezones = timeZonesMapper.getTimeZonesForNumber(phoneNumber);
The timezone metadata is auto-generated with few exceptions, so we cannot accept pull requests. If we have an error please file an issue and we'll see if we can make a generic fix.
If making fixes in your own fork while you wait for this, build the metadata by running this command from the root of the repository (assuming you have ant
installed):
ant -f java/build.xml build-timezones-data
Note that, due to our using stable CLDR timezone IDs, we do not change the ID for an existing timezone when the name of a region or subdivision changes. The library returns the ID, which you may use to get the localised name from CLDR.
See CLDR's documentation for timezone translations. You can also browse different languages' names; for example, the Asia/Calcutta
timezone identifier has English names Kolkata Time
and India Standard Time
, and the English file links to a view with other regions having the same timezone (including those with different IDs).
Other relevant CLDR data: