当前位置: 首页>>代码示例>>Java>>正文


Java TimeZoneRegistry类代码示例

本文整理汇总了Java中net.fortuna.ical4j.model.TimeZoneRegistry的典型用法代码示例。如果您正苦于以下问题:Java TimeZoneRegistry类的具体用法?Java TimeZoneRegistry怎么用?Java TimeZoneRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TimeZoneRegistry类属于net.fortuna.ical4j.model包,在下文中一共展示了TimeZoneRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: icalResponse

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
private GetEventsResponse icalResponse(Page<EventEntity> eventPage) {
    Calendar calendar = new Calendar();
    calendar.getProperties().add(new ProdId("-//PutPut//iCal4j 1.0//EN"));
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(CalScale.GREGORIAN);
    
    eventPage
            .getContent()
            .stream()
            .forEach(event -> {
                TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
                net.fortuna.ical4j.model.TimeZone timezone = registry.getTimeZone(event.getTimezone());
                
                VEvent vEvent = createVEvent(event, timezone);
                
                vEvent.getProperties().add(new Uid(event.getId()));
                vEvent.getProperties().add(new Description(event.getDescription()));
                vEvent.getProperties().add(new Location(event.getLocation()));
                vEvent.getProperties().add(timezone.getVTimeZone().getTimeZoneId());
                
                calendar.getComponents().add(vEvent);
            });
    
    return GetEventsResponse.withCalendarOK(calendar.toString());
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:26,代码来源:EventsResource.java

示例2: createCalendar

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
public static Calendar createCalendar(CalDavEvent calDavEvent, DateTimeZone timeZone) {
    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    TimeZone timezone = registry.getTimeZone(timeZone.getID());

    Calendar calendar = new Calendar();
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(new ProdId("openHAB"));
    VEvent vEvent = new VEvent();
    vEvent.getProperties().add(new Summary(calDavEvent.getName()));
    vEvent.getProperties().add(new Description(calDavEvent.getContent()));
    final DtStart dtStart = new DtStart(new net.fortuna.ical4j.model.DateTime(calDavEvent.getStart().toDate()));
    dtStart.setTimeZone(timezone);
    vEvent.getProperties().add(dtStart);
    final DtEnd dtEnd = new DtEnd(new net.fortuna.ical4j.model.DateTime(calDavEvent.getEnd().toDate()));
    dtEnd.setTimeZone(timezone);
    vEvent.getProperties().add(dtEnd);
    vEvent.getProperties().add(new Uid(calDavEvent.getId()));
    vEvent.getProperties().add(Clazz.PUBLIC);
    vEvent.getProperties()
            .add(new LastModified(new net.fortuna.ical4j.model.DateTime(calDavEvent.getLastChanged().toDate())));
    calendar.getComponents().add(vEvent);

    return calendar;
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:25,代码来源:Util.java

示例3: parseAppointmenttoCalendar

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
/**
 * Methods to parse Appointment to iCalendar according RFC 2445
 *
 * @param appointment to be converted to iCalendar
 * @return iCalendar representation of the Appointment
 */
public Calendar parseAppointmenttoCalendar(Appointment appointment) {
	String tzid = parseTimeZone(null, appointment.getOwner()).getID();

	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();

	net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
	if (timeZone == null) {
		throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
	}

	Calendar icsCalendar = new Calendar();
	icsCalendar.getProperties().add(new ProdId("-//Events Calendar//Apache Openmeetings//EN"));
	icsCalendar.getProperties().add(Version.VERSION_2_0);
	icsCalendar.getProperties().add(CalScale.GREGORIAN);
	icsCalendar.getComponents().add(timeZone.getVTimeZone());

	DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());

	VEvent meeting = new VEvent(start, end, appointment.getTitle());
	meeting = addVEventpropsfromAppointment(appointment, meeting);
	icsCalendar.getComponents().add(meeting);

	return icsCalendar;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:31,代码来源:IcalUtils.java

示例4: parseAppointmentstoCalendar

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
/**
 * Parses a List of Appointments into a VCALENDAR component.
 *
 * @param appointments List of Appointments for the Calendar
 * @param ownerId      Owner of the Appointments
 * @return VCALENDAR representation of the Appointments
 */
public Calendar parseAppointmentstoCalendar(List<Appointment> appointments, Long ownerId) {
	String tzid = parseTimeZone(null, userDao.get(ownerId)).getID();

	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();

	net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
	if (timeZone == null) {
		throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
	}

	Calendar icsCalendar = new Calendar();
	icsCalendar.getProperties().add(new ProdId(PROD_ID));
	icsCalendar.getProperties().add(Version.VERSION_2_0);
	icsCalendar.getProperties().add(CalScale.GREGORIAN);
	icsCalendar.getComponents().add(timeZone.getVTimeZone());

	for (Appointment appointment : appointments) {
		DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());

		VEvent meeting = new VEvent(start, end, appointment.getTitle());
		meeting = addVEventpropsfromAppointment(appointment, meeting);
		icsCalendar.getComponents().add(meeting);
	}
	return icsCalendar;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:33,代码来源:IcalUtils.java

示例5: printICalSchedule

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
protected void printICalSchedule(String calendarName, List<String> calRefs, OutputStream os)
//	protected void printICalSchedule(String calRef, OutputStream os) 
		throws PermissionException
	{
		// generate iCal text file 
		net.fortuna.ical4j.model.Calendar ical = new net.fortuna.ical4j.model.Calendar();
		ical.getProperties().add(new ProdId("-//SakaiProject//iCal4j 1.0//EN"));
		ical.getProperties().add(Version.VERSION_2_0);
		ical.getProperties().add(CalScale.GREGORIAN);
		ical.getProperties().add(new XProperty("X-WR-CALNAME", calendarName));
		ical.getProperties().add(new XProperty("X-WR-CALDESC", calendarName));
		
		TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); 
		TzId tzId = new TzId( m_timeService.getLocalTimeZone().getID() ); 
		ical.getComponents().add(registry.getTimeZone(tzId.getValue()).getVTimeZone());
		
		CalendarOutputter icalOut = new CalendarOutputter();
		int numEvents = generateICal(ical, calRefs);
			
		try 
		{
			if (numEvents > 0) {
				icalOut.output( ical, os );
			}
		}
		catch (Exception e)
		{
           log.warn(".printICalSchedule(): ", e);
		}
	}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:31,代码来源:BaseCalendarService.java

示例6: getTimeZone

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
public VTimeZone getTimeZone(boolean timeIsLocal) {
	//timezone. All dates are in GMT so we need to explicitly set that
	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
	
	//To prevent NPE on timezone
	TimeZone timezone = null;
	if (timeIsLocal == true) {
		timezone = registry.getTimeZone(timeService.getLocalTimeZone().getID());
	}
	if (timezone == null) {
		//This is guaranteed to return timezone if timeIsLocal == false or it fails and returns null
		timezone = registry.getTimeZone("GMT");
	}
	return timezone.getVTimeZone();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:ExternalCalendaringServiceImpl.java

示例7: clearTZRegistry

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
private static void clearTZRegistry(CalendarBuilder cb) {
    // clear timezone registry if present
    TimeZoneRegistry tzr = cb.getRegistry();
    if(tzr!=null) {
        tzr.clear();
    }
}
 
开发者ID:ksokol,项目名称:carldav,代码行数:8,代码来源:CalendarUtils.java

示例8: makeCalendar

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
protected static Calendar makeCalendar(GenericValue workEffort, Map<String, Object> context) throws GenericEntityException {
    String iCalData = null;
    GenericValue iCalValue = workEffort.getRelatedOne("WorkEffortIcalData", false);
    if (iCalValue != null) {
        iCalData = iCalValue.getString("icalData");
    }
    boolean newCalendar = true;
    Calendar calendar = null;
    if (iCalData == null) {
        Debug.logVerbose("iCalendar Data not found, creating new Calendar", module);
        calendar = new Calendar();
    } else {
        Debug.logVerbose("iCalendar Data found, using saved Calendar", module);
        StringReader reader = new StringReader(iCalData);
        CalendarBuilder builder = new CalendarBuilder();
        try {
            calendar = builder.build(reader);
            newCalendar = false;
        } catch (Exception e) {
            Debug.logError(e, "Error while parsing saved iCalendar, creating new iCalendar: ", module);
            calendar = new Calendar();
        }
    }
    PropertyList propList = calendar.getProperties();
    replaceProperty(propList, prodId);
    replaceProperty(propList, new XProperty(workEffortIdXPropName, workEffort.getString("workEffortId")));
    if (newCalendar) {
        propList.add(Version.VERSION_2_0);
        propList.add(CalScale.GREGORIAN);
        // TODO: Get time zone from publish properties value
        java.util.TimeZone tz = java.util.TimeZone.getDefault();
        TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
        net.fortuna.ical4j.model.TimeZone timezone = registry.getTimeZone(tz.getID());
        calendar.getComponents().add(timezone.getVTimeZone());
    }
    return calendar;
}
 
开发者ID:jamesyong,项目名称:o3erp,代码行数:38,代码来源:ICalConverter.java

示例9: getTimeZone

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
private TimeZone getTimeZone() {
	VTimeZone vTimeZone = (VTimeZone) getCalendar().getComponent(Component.VTIMEZONE);
	if (vTimeZone != null) {
		return new TimeZone(vTimeZone);
	}
	// TODO workaround
	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
	java.util.TimeZone default_timeZone = java.util.TimeZone.getDefault();
	TimeZone timezone = registry.getTimeZone(default_timeZone.getID());
	return timezone;
}
 
开发者ID:gillesB,项目名称:ical-import-export,代码行数:12,代码来源:InsertVEvents.java

示例10: createTestCalendar

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
/**
 * Creates test calendar instance.
 * 
 * @return ICal calendar object.
 */
protected Calendar createTestCalendar() throws ParseException {
 // Create a TimeZone
    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    TimeZone timezone = registry.getTimeZone("America/New_York");
    VTimeZone tz = timezone.getVTimeZone();

     // Start Date is on: April 1, 2013, 9:00 am
    java.util.Calendar startDate = new GregorianCalendar();
    startDate.setTimeZone(timezone);
    startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
    startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
    startDate.set(java.util.Calendar.YEAR, 2013);
    startDate.set(java.util.Calendar.HOUR_OF_DAY, 17);
    startDate.set(java.util.Calendar.MINUTE, 0);
    startDate.set(java.util.Calendar.SECOND, 0);

     // End Date is on: April 1, 2013, 13:00
    java.util.Calendar endDate = new GregorianCalendar();
    endDate.setTimeZone(timezone);
    endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
    endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
    endDate.set(java.util.Calendar.YEAR, 2013);
    endDate.set(java.util.Calendar.HOUR_OF_DAY, 21);
    endDate.set(java.util.Calendar.MINUTE, 0);  
    endDate.set(java.util.Calendar.SECOND, 0);

    // Create the event
    PropertyList propertyList = new PropertyList();
    propertyList.add(new DtStamp("20130324T180000Z"));
    propertyList.add(new DtStart(new DateTime(startDate.getTime())));
    propertyList.add(new DtEnd(new DateTime(endDate.getTime())));
    propertyList.add(new Summary("Progress Meeting"));
    VEvent meeting = new VEvent(propertyList);

    // add timezone info..
    meeting.getProperties().add(tz.getTimeZoneId());

    // generate unique identifier..
    meeting.getProperties().add(new Uid("00000000"));

    // add attendees..
    Attendee dev1 = new Attendee(URI.create("mailto:[email protected]"));
    dev1.getParameters().add(Role.REQ_PARTICIPANT);
    dev1.getParameters().add(new Cn("Developer 1"));
    meeting.getProperties().add(dev1);

    Attendee dev2 = new Attendee(URI.create("mailto:[email protected]"));
    dev2.getParameters().add(Role.OPT_PARTICIPANT);
    dev2.getParameters().add(new Cn("Developer 2"));
    meeting.getProperties().add(dev2);

    // Create a calendar
    net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
    icsCalendar.getProperties().add(Version.VERSION_2_0);
    icsCalendar.getProperties().add(new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
    icsCalendar.getProperties().add(CalScale.GREGORIAN);

    // Add the event and print
    icsCalendar.getComponents().add(meeting);
    return icsCalendar;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:67,代码来源:ICalDataFormatTest.java

示例11: simpleInvitionIcalLink

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
public void simpleInvitionIcalLink() {
	// Create a TimeZone
	TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
	TimeZone timezone = registry.getTimeZone("America/Mexico_City");
	VTimeZone tz = timezone.getVTimeZone();

	// Start Date is on: April 1, 2008, 9:00 am
	java.util.Calendar startDate = new GregorianCalendar();
	startDate.setTimeZone(timezone);
	startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
	startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
	startDate.set(java.util.Calendar.YEAR, 2008);
	startDate.set(java.util.Calendar.HOUR_OF_DAY, 9);
	startDate.set(java.util.Calendar.MINUTE, 0);
	startDate.set(java.util.Calendar.SECOND, 0);

	// End Date is on: April 1, 2008, 13:00
	java.util.Calendar endDate = new GregorianCalendar();
	endDate.setTimeZone(timezone);
	endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
	endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
	endDate.set(java.util.Calendar.YEAR, 2008);
	endDate.set(java.util.Calendar.HOUR_OF_DAY, 13);
	endDate.set(java.util.Calendar.MINUTE, 0);
	endDate.set(java.util.Calendar.SECOND, 0);

	// Create the event
	String eventName = "Progress Meeting";
	DateTime start = new DateTime(startDate.getTime());
	DateTime end = new DateTime(endDate.getTime());
	VEvent meeting = new VEvent(start, end, eventName);

	// add timezone info..
	meeting.getProperties().add(tz.getTimeZoneId());

	// generate unique identifier..
	Uid uid = new Uid(UUID.randomUUID().toString());
	meeting.getProperties().add(uid);

	// add attendees..
	Attendee dev1 = new Attendee(URI.create("mailto:[email protected]"));
	dev1.getParameters().add(Role.REQ_PARTICIPANT);
	dev1.getParameters().add(new Cn("Developer 1"));
	meeting.getProperties().add(dev1);

	Attendee dev2 = new Attendee(URI.create("mailto:[email protected]"));
	dev2.getParameters().add(Role.OPT_PARTICIPANT);
	dev2.getParameters().add(new Cn("Developer 2"));
	meeting.getProperties().add(dev2);

	// Create a calendar
	net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
	icsCalendar.getProperties().add(
			new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
	icsCalendar.getProperties().add(CalScale.GREGORIAN);
	icsCalendar.getProperties().add(Version.VERSION_2_0);

	// Add the event and print
	icsCalendar.getComponents().add(meeting);

	Organizer orger = new Organizer(URI.create("[email protected]"));
	orger.getParameters().add(new Cn("Sebastian Wagner"));
	meeting.getProperties().add(orger);

	icsCalendar.getProperties().add(Method.REQUEST);

	log.debug(icsCalendar.toString());

	ByteArrayOutputStream bout = new ByteArrayOutputStream();
	CalendarOutputter outputter = new CalendarOutputter();
	try {
		outputter.output(icsCalendar, bout);
		iCalMimeBody = bout.toByteArray();

		sendIcalMessage();
	} catch (Exception e) {
		log.error("Error", e);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:80,代码来源:TestSendIcalMessage.java

示例12: addEventsFromWorkItemList

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
/**
 * Put in the calendar an Event for each workitem
 * @param workItemList 
 * @param calendar
 */
private void addEventsFromWorkItemList(List<TWorkItemBean>  workItemList, Calendar calendar, Locale locale) throws IOException {
	
	for (Iterator<TWorkItemBean> it = workItemList.iterator(); it.hasNext();) {
		
		TWorkItemBean issue =it.next();
		
		//If it hasn't got any date, do nothing
		if (issue.getStartDate() != null || issue.getEndDate() != null ){
				
			// Create a TimeZone
			// TODO: It is needed to tests if it manages the daylight times
			final java.util.TimeZone serverTimeZone =  java.util.TimeZone.getDefault();
			
			TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
			TimeZone timezone = registry.getTimeZone(serverTimeZone.getID());
			VTimeZone tz = timezone.getVTimeZone();

			//set the event depending if it has start date and/or end date
			//always mark it as Full Day Task (it appears in the header of the day)
			VEvent issueEvent;
			java.util.Calendar startDate = new GregorianCalendar();
			startDate.setTimeZone(timezone);
			
			java.util.Calendar endDate = new GregorianCalendar();
			endDate.setTimeZone(timezone);
			
			if (issue.getStartDate() != null) {
				startDate.setTime(issue.getStartDate());
				if (issue.getEndDate() != null) { // startDate and endDate => use both
					endDate.setTime(issue.getEndDate());
				} else { // startDate and !endDate => use startDate
					endDate.setTime(issue.getStartDate());
				}
			}else{ // !startDate and endDate => use endDate
				startDate.setTime(issue.getEndDate());
				endDate.setTime(issue.getEndDate());
			}
			Integer responsibleID = issue.getResponsibleID();
			String description = issue.getDescription();
			if (description!=null) {
				try {
					description = Html2Text.getNewInstance().convert(description);
				} catch (Exception e) {
				}
			}
			if (startDate.equals(endDate)) {
				startDate.add(java.util.Calendar.DAY_OF_MONTH,1); 
				issueEvent = createEvent(new Date(startDate.getTime()),  new Date(startDate.getTime()), issue.getSynopsis(), issue.getObjectID(), description, responsibleID, tz);
				calendar.getComponents().add(issueEvent);
			} else {
				startDate.add(java.util.Calendar.DAY_OF_MONTH,1); 
				String title = LocalizeUtil.getParametrizedString("admin.myprefs.iCalendar.start", new Object[] {issue.getSynopsis()}, locale);
				issueEvent = createEvent(new Date(startDate.getTime()),  new Date(startDate.getTime()), title, issue.getObjectID(), description, responsibleID, tz);
				calendar.getComponents().add(issueEvent);
				endDate.add(java.util.Calendar.DAY_OF_MONTH,1);
				title = LocalizeUtil.getParametrizedString("admin.myprefs.iCalendar.end", new Object[] {issue.getSynopsis()}, locale);
				issueEvent = createEvent(new Date(endDate.getTime()),  new Date(endDate.getTime()), title, issue.getObjectID(), description, responsibleID, tz);
				calendar.getComponents().add(issueEvent);
				
			}
			// the period is [StartDate,EndDate)
		}
	}
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:70,代码来源:ICalendarSynchronizeAction.java

示例13: testConvertEvent

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
/**
 * Tests convert event.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Test
public void testConvertEvent() throws Exception {
    TimeZoneRegistry registry =
        TimeZoneRegistryFactory.getInstance().createRegistry();
    NoteItem master = new MockNoteItem();
    master.setDisplayName("displayName");
    master.setBody("body");
    master.setIcalUid("icaluid");
    master.setClientModifiedDate(new DateTime("20070101T100000Z"));
    EventStamp eventStamp = new MockEventStamp(master);
    eventStamp.createCalendar();
    eventStamp.setStartDate(new DateTime("20070212T074500"));
    master.addStamp(eventStamp);
    
    Calendar cal = converter.convertNote(master);
    cal.validate();
    
    // date has no timezone, so there should be no timezones
    Assert.assertEquals(0, cal.getComponents(Component.VTIMEZONE).size());
  
    eventStamp.setStartDate(new DateTime("20070212T074500",TIMEZONE_REGISTRY.getTimeZone("America/Chicago")));
    
    cal = converter.convertNote(master);
    cal.validate();
    
    // should be a single VEVENT
    ComponentList<VEvent> comps = cal.getComponents(Component.VEVENT);
    Assert.assertEquals(1, comps.size());
    VEvent event = (VEvent) comps.get(0);
    
    // test VALUE=DATE-TIME is not present
    Assert.assertNull(event.getStartDate().getParameter(Parameter.VALUE));
    
    // test item properties got merged into calendar
    Assert.assertEquals("displayName", event.getSummary().getValue());
    Assert.assertEquals("body", event.getDescription().getValue());
    Assert.assertEquals("icaluid", event.getUid().getValue());
    Assert.assertEquals(master.getClientModifiedDate().getTime(), event.getDateStamp().getDate().getTime());
     
    // date has timezone, so there should be a timezone
    Assert.assertEquals(1, cal.getComponents(Component.VTIMEZONE).size());
    
    eventStamp.setEndDate(new DateTime("20070212T074500",TIMEZONE_REGISTRY.getTimeZone("America/Los_Angeles")));
    
    cal = converter.convertNote(master);
    cal.validate();
    
    // dates have 2 different timezones, so there should be 2 timezones
    Assert.assertEquals(2, cal.getComponents(Component.VTIMEZONE).size());
    
    // add timezones to master event calendar
    eventStamp.getEventCalendar().getComponents().add(registry.getTimeZone("America/Chicago").getVTimeZone());
    eventStamp.getEventCalendar().getComponents().add(registry.getTimeZone("America/Los_Angeles").getVTimeZone());
    
    cal = converter.convertNote(master);
    cal.validate();
    Assert.assertEquals(2, cal.getComponents(Component.VTIMEZONE).size());
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:63,代码来源:EntityConverterTest.java

示例14: wrap

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
public void wrap(ContentValues values, VEvent vevent) {
    Property property = vevent.getProperty(keyVEvent);
    if (property != null) {
        try {
            Log.d(LOG_ID, "VEvent: " + keyVEvent + " GoogleEvent: " + keyGoogleEvent
                    + " Value: " + property.getValue());

            long timeInMillis = 0;
            Parameter parameter = property.getParameter("VALUE");
            if (parameter != null && parameter.getValue().equals("DATE")) {
                int year = Integer.parseInt(property.getValue().substring(0, 4));
                int month = Integer.parseInt(property.getValue().substring(4, 6));
                int day = Integer.parseInt(property.getValue().substring(6, 8));
                java.util.Calendar cal = java.util.Calendar.getInstance();
                cal.clear();
                cal.set(year, month - 1, day, 0, 0, 0);
                timeInMillis = cal.getTimeInMillis();
            } else {
                timeInMillis = dateToMillis(new DateTime(property.getValue()));
            }

            if (property.getParameter("TZID") != null) {
                String tzone = property.getParameter("TZID").getValue();
                if (tzone != null) {
                    TimeZoneRegistry registry = Controller.calendarBuilder.getRegistry();
                    TimeZone z = registry.getTimeZone(tzone);
                    if (z != null) {
                        Log.d(LOG_ID, "Adjusting timezone by " + z.getRawOffset());
                        int z1 = z.getRawOffset();

                        // Try to convert gmt GMT-05:00
                        int z2 = 0;
                        TimeZone currentZone = TimeZone.getDefault();
                        String dispName = currentZone.getDisplayName(true, TimeZone.SHORT);
                        if (dispName.startsWith("GMT")) {
                            int shift = 0;
                            if (dispName.matches("GMT[+].*")) {
                                shift++;
                            }
                            if (dispName.matches("GMT[+|-][0-9][0-9]:[0-9][0-9].*")) {
                                z2 = Integer.parseInt(dispName.substring(3 + shift, 6)) * 3600000;
                                z2 += ((z2 < 0) ? -1 : 1)
                                        * (Integer.parseInt(dispName.substring(7, 9)) * 60000);
                            } else if (dispName.matches("GMT[+|-][0-9][0-9].*")) {
                                z2 = Integer.parseInt(dispName.substring(3 + shift, 6)) * 3600000;
                            } else if (dispName.matches("GMT[+|-][0-9].*")) {
                                z2 = Integer.parseInt(dispName.substring(3 + shift, 5)) * 3600000;
                            }
                        } else {
                            z2 = currentZone.getRawOffset();
                        }

                        timeInMillis -= z1 - z2;

                    } else {
                        Log.d(LOG_ID, "Could not find timezone: " + tzone);
                    }
                }
                values.put("eventTimezone", tzone);
            }

            values.put(keyGoogleEvent, timeInMillis);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:gillesB,项目名称:ical-import-export,代码行数:68,代码来源:GoogleVEventWrapper.java

示例15: createTestCalendar

import net.fortuna.ical4j.model.TimeZoneRegistry; //导入依赖的package包/类
private Calendar createTestCalendar() throws ParseException {
    // Create a TimeZone
    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    TimeZone timezone = registry.getTimeZone("America/New_York");
    VTimeZone tz = timezone.getVTimeZone();

    // Start Date is on: April 1, 2013, 9:00 am
    java.util.Calendar startDate = new GregorianCalendar();
    startDate.setTimeZone(timezone);
    startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
    startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
    startDate.set(java.util.Calendar.YEAR, 2013);
    startDate.set(java.util.Calendar.HOUR_OF_DAY, 17);
    startDate.set(java.util.Calendar.MINUTE, 0);
    startDate.set(java.util.Calendar.SECOND, 0);

    // End Date is on: April 1, 2013, 13:00
    java.util.Calendar endDate = new GregorianCalendar();
    endDate.setTimeZone(timezone);
    endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
    endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
    endDate.set(java.util.Calendar.YEAR, 2013);
    endDate.set(java.util.Calendar.HOUR_OF_DAY, 21);
    endDate.set(java.util.Calendar.MINUTE, 0);
    endDate.set(java.util.Calendar.SECOND, 0);

    // Create the event
    PropertyList propertyList = new PropertyList();
    propertyList.add(new DtStamp("20130324T180000Z"));
    propertyList.add(new DtStart(new DateTime(startDate.getTime())));
    propertyList.add(new DtEnd(new DateTime(endDate.getTime())));
    propertyList.add(new Summary("Progress Meeting"));
    VEvent meeting = new VEvent(propertyList);

    // add timezone info..
    meeting.getProperties().add(tz.getTimeZoneId());

    // generate unique identifier..
    meeting.getProperties().add(new Uid("00000000"));

    // add attendees..
    Attendee dev1 = new Attendee(URI.create("mailto:[email protected]"));
    dev1.getParameters().add(Role.REQ_PARTICIPANT);
    dev1.getParameters().add(new Cn("Developer 1"));
    meeting.getProperties().add(dev1);

    Attendee dev2 = new Attendee(URI.create("mailto:[email protected]"));
    dev2.getParameters().add(Role.OPT_PARTICIPANT);
    dev2.getParameters().add(new Cn("Developer 2"));
    meeting.getProperties().add(dev2);

    // Create a calendar
    net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
    icsCalendar.getProperties().add(Version.VERSION_2_0);
    icsCalendar.getProperties().add(new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
    icsCalendar.getProperties().add(CalScale.GREGORIAN);

    // Add the event and print
    icsCalendar.getComponents().add(meeting);
    return icsCalendar;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:62,代码来源:ICalFormatTest.java


注:本文中的net.fortuna.ical4j.model.TimeZoneRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。