Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JWebServices for Exchange
>
Tutorial
> Get server time zones
The following example shows you how to get server time zones.
import com.independentsoft.exchange.GetServerTimeZonesResponse; import com.independentsoft.exchange.RequestServerVersion; import com.independentsoft.exchange.Service; import com.independentsoft.exchange.ServiceException; import com.independentsoft.exchange.TimeZoneDefinition; public class Example { public static void main(String[] args) { try { Service service = new Service("https://myserver/ews/Exchange.asmx", "username", "password"); service.setRequestServerVersion(RequestServerVersion.EXCHANGE_2010_SP1); GetServerTimeZonesResponse response = service.getServerTimeZones(); //Display all available time zones for (TimeZoneDefinition timeZone : response.getTimeZoneDefinitions()) { System.out.println(timeZone.getId()); System.out.println(timeZone.getName()); System.out.println("-------------------------------------------------------"); } //Display time zones with offset -05:00 for (TimeZoneDefinition timeZone : response.getTimeZoneDefinitions()) { if (timeZone.getName().indexOf("UTC-05:00") > 0) { System.out.println(timeZone.getId()); System.out.println(timeZone.getName()); System.out.println("-------------------------------------------------------"); } } //Find time zone based on name for (TimeZoneDefinition timeZone : response.getTimeZoneDefinitions()) { if (timeZone.getName().indexOf("Dublin") > 0) { System.out.println(timeZone.getId()); System.out.println(timeZone.getName()); System.out.println("-------------------------------------------------------"); } } } catch (ServiceException e) { System.out.println(e.getMessage()); System.out.println(e.getXmlMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*