Hello Mikywan,

The gd:when element has a property named "gCal:displayTimezone" that specify 
the display timezone to used:

[ATOM]
<gd:when endTime="2011-05-17T15:00:00.000-08:00" 
startTime="2011-05-17T17:00:00.000-08:00">
  <gd:reminder method="alert" minutes="10"/>
  <gCal:displayTimezone end="Europe/Warsaw" start="Europe/Paris"/>
</gd:when>
[ATOM]

Unfortunately, the Java client library doesn't support his property. But you 
can add it by using the attached Java class and use it like this:

[CODE]
      
    When eventTimes = new When();

    DateTime startTime = DateTime.parseDateTime("2011-05-17T15:00:00-08:00"
);

    DateTime endTime = DateTime.parseDateTime("2011-05-17T17:00:00-08:00");


    eventTimes.setStartTime(startTime);

    eventTimes.setEndTime(endTime);

    eventTimes.setExtension(new *DisplayTimezoneProperty*("Europe/Paris", 
"Europe/Warsaw"));

    eventEntry.addTime(eventTimes);
[/CODE]

I hope this helped!

Best,
Alain

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html
/*
 * Copyright (c) 2011 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.gdata.data.calendar;

import com.google.gdata.data.AttributeGenerator;
import com.google.gdata.data.AttributeHelper;
import com.google.gdata.data.ExtensionDescription;
import com.google.gdata.data.ExtensionPoint;
import com.google.gdata.util.ParseException;

/**
 * Indicate the event display timezone.
 */
@ExtensionDescription.Default(nsAlias = Namespaces.gCalAlias, nsUri = Namespaces.gCal, localName = DisplayTimezoneProperty.XML_NAME)
public class DisplayTimezoneProperty extends ExtensionPoint {

  /** XML element name */
  static final String XML_NAME = "displayTimezone";

  /** XML "start" attribute name */
  private static final String START = "start";

  /** XML "end" attribute name */
  private static final String END = "end";

  /** Start */
  private String start = null;

  /** End */
  private String end = null;

  /**
   * Default mutable constructor.
   */
  public DisplayTimezoneProperty() {
    super();
  }

  /**
   * Immutable constructor.
   * 
   * @param start start.
   */
  public DisplayTimezoneProperty(String start) {
    super();
    setStart(start);
    setImmutable(true);
  }

  /**
   * Immutable constructor.
   * 
   * @param start start.
   * @param end end.
   */
  public DisplayTimezoneProperty(String start, String end) {
    super();
    setStart(start);
    setEnd(end);
    setImmutable(true);
  }

  /**
   * Returns the start timezone property.
   * 
   * @return start
   */
  public String getStart() {
    return start;
  }

  /**
   * Returns the end timezone property.
   * 
   * @return start
   */
  public String getEnd() {
    return end;
  }

  /**
   * Sets the start timezone property.
   * 
   * @param value value or <code>null</code> to reset
   */
  public void setStart(String start) {
    throwExceptionIfImmutable();
    this.start = start;
  }

  /**
   * Sets the end timezone property.
   * 
   * @param value value or <code>null</code> to reset
   */
  public void setEnd(String end) {
    throwExceptionIfImmutable();
    this.end = end;
  }

  /**
   * Returns whether it has the start property.
   * 
   * @return whether it has the start property
   */
  public boolean hasStart() {
    return getStart() != null;
  }

  /**
   * Returns whether it has the end property.
   * 
   * @return whether it has the end property
   */
  public boolean hasEnd() {
    return getEnd() != null;
  }

  @Override
  protected void validate() {
    if (start == null) {
      throwExceptionForMissingAttribute(START);
    }
  }

  /**
   * Returns the extension description, specifying whether it is required, and
   * whether it is repeatable.
   * 
   * @param required whether it is required
   * @param repeatable whether it is repeatable
   * @return extension description
   */
  public static ExtensionDescription getDefaultDescription(boolean required, boolean repeatable) {
    ExtensionDescription desc = ExtensionDescription
        .getDefaultDescription(DisplayTimezoneProperty.class);
    desc.setRequired(required);
    desc.setRepeatable(repeatable);
    return desc;
  }

  @Override
  protected void putAttributes(AttributeGenerator generator) {
    generator.put(START, start);
    if (hasEnd()) {
      generator.put(END, end);
    }
  }

  @Override
  protected void consumeAttributes(AttributeHelper helper) throws ParseException {
    start = helper.consume(START, true);
    end = helper.consume(END, false);
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (!sameClassAs(obj)) {
      return false;
    }
    DisplayTimezoneProperty other = (DisplayTimezoneProperty) obj;
    return eq(start, other.start) && eq(end, other.end);
  }

  @Override
  public int hashCode() {
    int result = getClass().hashCode() * 37;
    if (start != null) {
      result = result + start.hashCode();
    }
    if (end != null) {
      result = 37 * result + end.hashCode();
    }
    return result;
  }

  @Override
  public String toString() {
    return "{DisplayTimezoneProperty start=" + start + " end=" + end + "}";
  }
}

Reply via email to