Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Appointment via EWS shows UTC instead of local TZ #398

Closed
bhagyagdesai opened this issue Aug 10, 2015 · 11 comments
Closed

Updated Appointment via EWS shows UTC instead of local TZ #398

bhagyagdesai opened this issue Aug 10, 2015 · 11 comments
Labels

Comments

@bhagyagdesai
Copy link

Hi All
I have researched for this issue and am unable to find a solution.

Updated Appointment via EWS shows UTC instead of local TZ in attendee's calender event notification mail

Here is what's wrong:
in when it showing time in UTC instead of local timezone ie (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi . both timing has 05:30 difference so it create confusion,Both timing should be same.
image

@serious6 serious6 added the bug label Aug 10, 2015
@rajeshpatil1012
Copy link

@itbw please look into this issue

@ghost
Copy link

ghost commented Aug 14, 2015

@rajeshpatil1012 I think this is related to #357.

@rajeshpatil1012
Copy link

@itbw Thanks for your reply !!
waiting for your reply

@rajeshpatil1012
Copy link

Hi @itbw i tried following code in ServiceRequestBase.java class just giving hard coded value then i got correct result
when try whih dynamic value setting bias i have issue, how to set Bias in this java file
I think that is only option to change api ServiceRequestBase.java file to set correct time in notification mail in java

// Emit the RequestServerVersion header
if ((this.getService().getRequestedServerVersion().ordinal() == ExchangeVersion.Exchange2010_SP1.ordinal()))
{

    writer.writeStartElement(XmlNamespace.Types,
            XmlElementNames.RequestServerVersion);
    writer.writeAttributeValue(XmlAttributeNames.Version, this
            .getRequestedServiceVersionString());
    writer.writeEndElement(); /// RequestServerVersion

    writer.writeStartElement(XmlNamespace.Types,XmlElementNames.TimeZoneContext);

      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.TimeZoneDefinition);

      String timeZonePretty=null;
      TimeZone timeZone = null;*/
      int hours,minutes,days,seconds,milliseconds;
         for (String timeZoneId: TimeZone.getAvailableIDs()) {
              timeZone = TimeZone.getTimeZone(timeZoneId);


              //Filter out timezone IDs such as "GMT+3"; more thorough filtering is required though
              if (!timeZoneId.matches(".*/.*")) {
                 continue;
             }

              String region = timeZoneId.replaceAll(".*/", "").replaceAll("_", " ");

              hours = Math.abs(timeZone.getRawOffset()) / 3600000;
              minutes = Math.abs(timeZone.getRawOffset() / 60000) % 60;

             String sign = timeZone.getRawOffset() >= 0 ? "+" : "-";

             if(TimeZone.getDefault().getID().equals(timeZoneId))
             {
            timeZonePretty = String.format("(UTC %s %02d:%02d) %s", sign, hours, minutes, region);
            System.out.println(timeZonePretty);
             }
          }
          //System.out.println(timeZone.getDisplayName());
          Collection<TimeZoneDefinition> t = service.getServerTimeZones();              

            TimeZoneDefinition tf = null;
            for (TimeZoneDefinition timeZoneDefinition : t) 
            {

                if(timeZoneDefinition.getId().equalsIgnoreCase(TimeZone.getDefault().getID()))
                {
                    tf = timeZoneDefinition;
                    break;
                }
            }


             String offsetStr = (timeOffset.getTotalSeconds() < 0) ? "-" : "";
            String sss= "-" + "P" + days + "DT" + hours + "H" + minutes + "M"
               + seconds + "." + milliseconds + "S";

            System.out.println(new Date().getTimezoneOffset());






      writer.writeAttributeValue(XmlAttributeNames.Name,timeZonePretty);
     writer.writeAttributeValue(XmlAttributeNames.Id,TimeZone.getDefault().getDisplayName());
     // writer.writeAttributeValue(XmlAttributeNames.Name,this
            //  );
     // writer.writeAttributeValue(XmlAttributeNames.Id,"India Standard Time");
      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Periods);

      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Period);
      writer.writeAttributeValue(XmlAttributeNames.Bias,"-P0DT5H30M0.0S" );
      writer.writeAttributeValue(XmlAttributeNames.Name,"Standard" );
      writer.writeAttributeValue(XmlAttributeNames.Id,"Std");




      writer.writeEndElement();
      writer.writeEndElement();

      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.TransitionsGroups);          
      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.TransitionsGroup);
      writer.writeAttributeValue(XmlAttributeNames.Id,"0");



      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Transition);
      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.To);
      writer.writeAttributeValue(XmlAttributeNames.Kind,"Period");
       writer.writeValue("Std", XmlElementNames.To);

      writer.writeEndElement();
      writer.writeEndElement();
      writer.writeEndElement();
      writer.writeEndElement();


      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Transitions);
      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Transition);
      writer.writeStartElement(XmlNamespace.Types, XmlElementNames.To);
      writer.writeAttributeValue(XmlAttributeNames.Kind,"Group");
       writer.writeValue("0", XmlElementNames.To);


      writer.writeEndElement();
      writer.writeEndElement();
      writer.writeEndElement();

      writer.writeEndElement();
      writer.writeEndElement();
    }



    if (this.service.getPreferredCulture() != null) {
        writer.writeElementValue(XmlNamespace.Types,
                XmlElementNames.MailboxCulture, this.service
                .getPreferredCulture().getDisplayName());
    }
    if (this.service.getImpersonatedUserId() != null) {
        this.service.getImpersonatedUserId().writeToXml(writer);
    }

    if (this.service.getCredentials() != null) {
        this.service.getCredentials().serializeExtraSoapHeaders(
                writer.getInternalWriter(), this.getXmlElementName());
    }
    this.service.doOnSerializeCustomSoapHeaders(writer.getInternalWriter());

    writer.writeEndElement(); // soap:Header

    writer.writeStartElement(XmlNamespace.Soap,
            XmlElementNames.SOAPBodyElementName);

    this.writeBodyToXml(writer);

    writer.writeEndElement(); // soap:Body
    writer.writeEndElement(); // soap:Envelope
    writer.flush();
}

serious6 added a commit that referenced this issue Aug 30, 2015
Fix: XSDuration in EWSUtilities (#357, #398, #343)
@selamialtin
Copy link

I'm currently using 2.1-snapshot but still have same bug, how to disable when message in body, i set start and end time zone but still message is UTC format

            Appointment meeting = new Appointment(exchangeSender.service);
            // Set the properties on the meeting object to create the meeting.
            TimeZoneDefinition td = null
            exchangeSender.service.serverTimeZones.each {
                if (it.id.equals("Turkey Standard Time")) {
                    td = it
                } 
            }
            meeting.subject = args.subject;
            meeting.body = new MessageBody(args.body)
            meeting.start = args.start
            meeting.end = args.end
            meeting.location = args.location
            meeting.isAllDayEvent = false

// meeting.startTimeZone = new OlsonTimeZoneDefinition(TimeZone.getTimeZone('Europe/Istanbul'))
// meeting.endTimeZone = new OlsonTimeZoneDefinition(TimeZone.getTimeZone('Europe/Istanbul'))
meeting.startTimeZone = td
meeting.endTimeZone = td

.

image

@Prathyushasdp
Copy link

I am also using 2.1-snapshot and I observed same issue in meeting invitation while creating appointment not only while updating.

@selamialtin
Copy link

I changed exchange version to Exchange2007_SP1 and solved problem also set only startTimeZone like this. I hope this will help you.

exchangeSender.service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
Appointment meeting = new Appointment(exchangeSender.service);
meeting.subject = args.subject;
meeting.body = new MessageBody(args.body)
meeting.start = args.start
meeting.end = args.end
meeting.location = args.location
meeting.isAllDayEvent = false
meeting.startTimeZone = new OlsonTimeZoneDefinition(TimeZone.getTimeZone('Europe/Istanbul'))
meeting.reminderMinutesBeforeStart = 15;

@Prathyushasdp
Copy link

@selamialtin thanks for your suggestion

I am dealing with Microsoft Exchange server 2010 SP2 so I have to use ExchangeVersion.Exchange2010_SP2 to get exchange service otherwise I can not perform other operations

@selamialtin
Copy link

Yes, we are using excahge server 2010 sp2 too, you should use the ews service as ExchangeVersion.Exchange2007_SP1 while sending appointment, no problem.

@Prathyushasdp
Copy link

@selamialtin thank you so much. It is working after setting ExchangeVersion.Exchange2007_SP1 while sending appointment.

@stulife
Copy link

stulife commented Dec 28, 2018

@bhagyagdesai

Hi All
I have researched for this issue and am unable to find a solution.

Updated Appointment via EWS shows UTC instead of local TZ in attendee's calender event notification mail

Here is what's wrong:
in when it showing time in UTC instead of local timezone ie (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi . both timing has 05:30 difference so it create confusion,Both timing should be same.
image

How did this problem be solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants