net.fortuna.ical4j.model.TimeZone类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中net.fortuna.ical4j.model.TimeZone类的一些代码示例,展示了TimeZone类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeZone类的具体详情如下:
包路径:net.fortuna.ical4j.model.TimeZone
类名称:TimeZone

TimeZone介绍

[英]$Id$

Created on 13/09/2005

A Java timezone implementation based on an underlying VTimeZone definition.
[中]$Id$
创建于2005年9月13日
基于底层VTimeZone定义的Java时区实现。

代码示例

代码示例来源:origin: org.bedework.ical4j/ical4j

/**
 * {@inheritDoc}
 */
public final void register(final TimeZone timezone, boolean update) {
  if (update) {
    // load any available updates for the timezone..
    timezones.put(timezone.getID(), new TimeZone(updateDefinition(timezone.getVTimeZone())));
  } else {
    timezones.put(timezone.getID(), timezone);
  }
}

代码示例来源:origin: ical4j/ical4j

/**
 * Reset the timezone to default.
 */
private void resetTimeZone() {
  // use GMT timezone to avoid daylight savings rules affecting floating
  // time values..
  getFormat().setTimeZone(TimeZone.getDefault());
  // getFormat().setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID));
}

代码示例来源:origin: ical4j/ical4j

/**
 * Constructs a new instance based on the specified VTimeZone.
 *
 * @param vTimeZone a VTIMEZONE object instance
 */
public TimeZone(final VTimeZone vTimeZone) {
  this.vTimeZone = vTimeZone;
  final TzId tzId = vTimeZone.getProperty(Property.TZID);
  setID(tzId.getValue());
  this.rawOffset = getRawOffset(vTimeZone);
}

代码示例来源:origin: ical4j/ical4j

/**
 * {@inheritDoc}
 */
public final void register(final TimeZone timezone, boolean update) {
  if (update) {
    try {
      // load any available updates for the timezone..
      timezones.put(timezone.getID(), new TimeZone(timeZoneLoader.loadVTimeZone(timezone.getID())));
    } catch (IOException | ParserException | ParseException e) {
      Logger log = LoggerFactory.getLogger(TimeZoneRegistryImpl.class);
      log.warn("Error occurred loading VTimeZone", e);
    }
  } else {
    timezones.put(timezone.getID(), timezone);
  }
}

代码示例来源:origin: miltonio/milton2

@Override
  void mapToCard(net.fortuna.ical4j.model.Calendar cal, Object bean, PropertyDescriptor pd) {
    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    String tzId = propertyAccessor.get(bean, pd.getReadMethod(), String.class);
    TimeZone timezone = null;
    if (tzId != null && tzId.length() > 0) {
      timezone = registry.getTimeZone(tzId); // Eg Pacific/Auckland
    }
    // TODO: do we need to use a default time zone if none given?
    if (timezone != null) {
      VTimeZone tz = timezone.getVTimeZone();
      cal.getComponents().add(tz);
    }
  }
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

/**
   * Register.
   * @param timezone The timezone.
   * @param update The boolean for update.
   */
  // @Override
  public void register(TimeZone timezone, boolean update) {
    timezones.put(timezone.getID(), timezone);

  }
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

/**
 * Return ical4j TimeZone instance for timezone id.
 * @param id timezone id
 * @return ical4j TimeZone instance
 */
public static net.fortuna.ical4j.model.TimeZone getTimeZone(String id) {
  if(!allTimezoneIds.contains(id)) {
    return null;
  } 
  
  VTimeZone vtz = getVTimeZone(id);
  if(vtz==null) {
    return null;
  }
  
  return new net.fortuna.ical4j.model.TimeZone(vtz);
}

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

/**
 * Constructs an <code>ICalDate</code> from an iCalendar date
 * list. Date lists cannot be anytime.
 * @param dates The date list.
 * @throws UnknownTimeZoneException - if something is wrong this exception is thrown.
 */
public ICalDate(DateList dates) throws UnknownTimeZoneException {
  value = dates.getType();
  tz = dates.getTimeZone();
  if (tz != null) {
    String origId = tz.getID();
    tz = tzTranslator.translateToOlsonTz(tz);
    if (tz == null) {
      throw new UnknownTimeZoneException(origId);
    }
    String id = tz.getVTimeZone().getProperties().
      getProperty(Property.TZID).getValue();
    tzid = new TzId(id);
  }
  text = dates.toString();
  this.dates = dates;
}

代码示例来源:origin: Baralga/baralga

TimeZone timeZone = registry.getTimeZone(TimeZone.getDefault().getID());
if (timeZone == null) {
  timeZone = registry.getTimeZone(DEFAULT_TIME_ZONE_IDENTIFIER);
final VTimeZone vTimeZone = timeZone.getVTimeZone();
final TzId timeZoneId = vTimeZone.getTimeZoneId();

代码示例来源:origin: org.bedework/bw-ical4j-cl

protected Object initialValue() {
    final DateFormat format = new SimpleDateFormat(UTC_PATTERN);
    format.setTimeZone(TimeZone.getTimeZone(TimeZones.UTC_ID));
    format.setLenient(false);
    return (Object)format;
  }
};

代码示例来源:origin: ical4j/ical4j

/**
 * Assert the raw offset is the same as its Java equivalent.
 */
public void testGetRawOffset() {
  assertEquals(expectedRawOffset, timezone.getRawOffset());
  assertEquals(tz.getRawOffset(), timezone.getRawOffset());
}

代码示例来源:origin: ical4j/ical4j

utcTz.setID(TimeZones.UTC_ID);

代码示例来源:origin: org.bedework.caleng/bw-calendar-engine-ical

private void addIcalTimezone(final Calendar cal, final String tzid,
               final TreeSet<String> added,
               final TimeZoneRegistry tzreg) throws CalFacadeException {
 VTimeZone vtz = null;
 if ((tzid == null) ||
   ((added != null) && added.contains(tzid))) {
  return;
 }
 //if (debug()) {
 //  debug("Look for timezone with id " + tzid);
 //}
 TimeZone tz = tzreg.getTimeZone(tzid);
 if (tz != null) {
  vtz = tz.getVTimeZone();
 }
 if (vtz != null) {
  //if (debug()) {
  //  debug("found timezone with id " + tzid);
  //}
  cal.getComponents().add(vtz);
 } else if (debug()) {
  debug("Didn't find timezone with id " + tzid);
 }
 if (added != null) {
  added.add(tzid);
 }
}

代码示例来源:origin: 1and1/cosmo

/**
   * Register.
   * @param timezone The timezone.
   * @param update The boolean for update.
   */
  // @Override
  public void register(TimeZone timezone, boolean update) {
    timezones.put(timezone.getID(), timezone);

  }
}

代码示例来源:origin: org.mnode.ical4j/ical4j

/**
 * {@inheritDoc}
 */
public final void register(final TimeZone timezone, boolean update) {
  if (update) {
    try {
      // load any available updates for the timezone..
      timezones.put(timezone.getID(), new TimeZone(timeZoneLoader.loadVTimeZone(timezone.getID())));
    } catch (IOException | ParserException | ParseException e) {
      Logger log = LoggerFactory.getLogger(TimeZoneRegistryImpl.class);
      log.warn("Error occurred loading VTimeZone", e);
    }
  } else {
    timezones.put(timezone.getID(), timezone);
  }
}

代码示例来源:origin: 1and1/cosmo

/**
 * Return ical4j TimeZone instance for timezone id.
 * @param id timezone id
 * @return ical4j TimeZone instance
 */
public static net.fortuna.ical4j.model.TimeZone getTimeZone(String id) {
  if(!allTimezoneIds.contains(id)) {
    return null;
  } 
  
  VTimeZone vtz = getVTimeZone(id);
  if(vtz==null) {
    return null;
  }
  
  return new net.fortuna.ical4j.model.TimeZone(vtz);
}

代码示例来源:origin: 1and1/cosmo

/**
 * Constructs an <code>ICalDate</code> from an iCalendar date
 * list. Date lists cannot be anytime.
 * @param dates The date list.
 * @throws UnknownTimeZoneException - if something is wrong this exception is thrown.
 */
public ICalDate(DateList dates) throws UnknownTimeZoneException {
  value = dates.getType();
  tz = dates.getTimeZone();
  if (tz != null) {
    String origId = tz.getID();
    tz = tzTranslator.translateToOlsonTz(tz);
    if (tz == null) {
      throw new UnknownTimeZoneException(origId);
    }
    String id = tz.getVTimeZone().getProperties().
      getProperty(Property.TZID).getValue();
    tzid = new TzId(id);
  }
  text = dates.toString();
  this.dates = dates;
}

代码示例来源:origin: ical4j/ical4j

/**
   * {@inheritDoc}
   */
  public String toString() {
    // if time is floating avoid daylight saving rules when generating
    // string representation of date..
    final java.util.TimeZone timeZone = format.getTimeZone();
    if (!(timeZone instanceof TimeZone)) {
      if (gmtFormat == null) {
        gmtFormat = (DateFormat) format.clone();
        gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID));
      }
      if (timeZone.inDaylightTime(this)
          && timeZone.inDaylightTime(new Date(getTime() - 1))) {

        return gmtFormat.format(new Date(getTime()
            + timeZone.getRawOffset()
            + timeZone.getDSTSavings()));
//                return format.format(new Date(getTime() - format.getTimeZone().getDSTSavings()));
      }
//            return gmtFormat.format(new Date(getTime() + format.getTimeZone().getOffset(getTime())));
      return gmtFormat.format(new Date(getTime() + timeZone.getRawOffset()));
    }
    return format.format(this);
  }

代码示例来源:origin: org.mnode.ical4j/ical4j

/**
 * {@inheritDoc}
 */
public int getOffset(long date) {
  final Observance observance = vTimeZone.getApplicableObservance(new DateTime(date));
  if (observance != null) {
    final TzOffsetTo offset = observance.getProperty(Property.TZOFFSETTO);
    if ((offset.getOffset().getTotalSeconds() * 1000L) < getRawOffset()) {
      return getRawOffset();
    } else {
      return (int) (offset.getOffset().getTotalSeconds() * 1000L);
    }
  }
  return 0;
}

代码示例来源:origin: micromata/projectforge

public VEvent convertVEvent(final TeamEventDO event)
{
 final ICalConverterStore store = ICalConverterStore.getInstance();
 // create vEvent
 final VEvent vEvent = new VEvent(false);
 // set time zone
 if (this.timeZone != null) {
  final net.fortuna.ical4j.model.TimeZone timezone = TIMEZONE_REGISTRY.getTimeZone(this.timeZone.getID());
  vEvent.getProperties().add(timezone.getVTimeZone().getTimeZoneId());
 }
 for (String export : this.exportsVEvent) {
  VEventComponentConverter converter = store.getVEventConverter(export);
  if (converter == null) {
   log.warn(String.format("No converter found for '%s', converter is skipped", export));
   continue;
  }
  converter.toVEvent(event, vEvent);
 }
 return vEvent;
}

相关文章