none
[EWS Java API 2.1][JAVA] Invalid TimeZoneDefinitions RRS feed

  • Question

  • I'm using Exchange Web Services 2.1 against Exchange version V2017_07_11 using Java.

    I'm trying to create Appointments in various timezones but I'm finding that a lot of the TimeZoneDefinitions returned by the server are not valid and cannot be used.

    Here's a snippet that illustrates the problem:

    Collection<TimeZoneDefinition> serverTimeZones = ews.getService().getServerTimeZones() ;
    for (TimeZoneDefinition tzd : serverTimeZones) {
    	boolean valid = true ;
    	try {
    		tzd.validate() ;
    	} catch (Exception e) {
    		valid = false ;
    	}				
    				
    	if (!valid) {
    		log.logInfo("Zone: Name=" + tzd.getName() + " ID=" + tzd.getId() + " Valid=" + valid);					
    	}
    }

    The result looks something like this:

    2017-09-06 04:33:13 INFO Zone: Name=(UTC+13:00) Samoa ID=Samoa Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-10:00) Aleutian Islands ID=Aleutian Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-09:00) Alaska ID=Alaskan Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-08:00) Baja California ID=Pacific Standard Time (Mexico) Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-08:00) Pacific Time (US & Canada) ID=Pacific Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-07:00) Mountain Time (US & Canada) ID=Mountain Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-05:00) Chetumal ID=Eastern Standard Time (Mexico) Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-06:00) Central Time (US & Canada) ID=Central Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-06:00) Easter Island ID=Easter Island Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-04:00) Turks and Caicos ID=Turks And Caicos Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-05:00) Eastern Time (US & Canada) ID=Eastern Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-05:00) Haiti ID=Haiti Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-05:00) Havana ID=Cuba Standard Time Valid=false
    2017-09-06 04:33:13 INFO Zone: Name=(UTC-05:00) Indiana (East) ID=US Eastern Standard Time Valid=false
    (other invalid timezones omitted for brevity)

    Out of the 135 TimeZoneDefinitions defined by the server, 78 of them do not pass validation.

    If I try to use any of the invalid timezones on a new Appointment I get the following exception:

    Caused by: microsoft.exchange.webservices.data.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException
    	at microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition.validate(TimeZoneDefinition.java:347)
    	at microsoft.exchange.webservices.data.core.PropertyBag.validatePropertyValue(PropertyBag.java:740)
    	at microsoft.exchange.webservices.data.core.PropertyBag.validate(PropertyBag.java:718)
    	at microsoft.exchange.webservices.data.core.service.ServiceObject.validate(ServiceObject.java:281)
    	at microsoft.exchange.webservices.data.core.service.item.Item.validate(Item.java:503)
    	at microsoft.exchange.webservices.data.core.service.item.Appointment.validate(Appointment.java:245)
    	at microsoft.exchange.webservices.data.core.request.CreateItemRequest.validate(CreateItemRequest.java:79)
    	at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:634)
    	at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:62)

    Can anyone explain why so many of the TimeZoneDefinitions are invalid and what I can do about it?

    Edited To Add:

    I have built the ews jar from the master branch in GIT and edited the TimeZoneDefinition.validate() method so that it never throws an exception. If I use the new jar I now get the following exception:

    microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: The first transition can be only of TransitionType., The first transition can be only of TransitionType.
    	at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
    	at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
    	at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
    	at microsoft.exchange.webservices.data.core.ExchangeService.internalCreateItems(ExchangeService.java:598)
    	at microsoft.exchange.webservices.data.core.ExchangeService.createItem(ExchangeService.java:657)
    	at microsoft.exchange.webservices.data.core.service.item.Item.internalCreate(Item.java:245)
    	at microsoft.exchange.webservices.data.core.service.item.Appointment.save(Appointment.java:404)
    


    • Edited by Keith Smillie Wednesday, September 6, 2017 4:48 PM Built jar from Master and modified the validate() method.
    Wednesday, September 6, 2017 3:43 PM