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


Java TimeZone.getVTimeZone方法代码示例

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


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

示例1: getTimeZone

import net.fortuna.ical4j.model.TimeZone; //导入方法依赖的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

示例2: createTestCalendar

import net.fortuna.ical4j.model.TimeZone; //导入方法依赖的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

示例3: simpleInvitionIcalLink

import net.fortuna.ical4j.model.TimeZone; //导入方法依赖的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

示例4: addEventsFromWorkItemList

import net.fortuna.ical4j.model.TimeZone; //导入方法依赖的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

示例5: createTestCalendar

import net.fortuna.ical4j.model.TimeZone; //导入方法依赖的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

示例6: okPressed

import net.fortuna.ical4j.model.TimeZone; //导入方法依赖的package包/类
@Override
protected void okPressed(){
	von.setTimeInMillis(dpVon.getDate().getTime());
	bis.setTimeInMillis(dpBis.getDate().getTime());
	Query<Termin> qbe = new Query<Termin>(Termin.class);
	qbe.add(Termin.FLD_TAG, Query.GREATER_OR_EQUAL, von.toString(TimeTool.DATE_COMPACT));
	qbe.add(Termin.FLD_TAG, Query.LESS_OR_EQUAL, bis.toString(TimeTool.DATE_COMPACT));
	qbe.add(Termin.FLD_BEREICH, Query.EQUALS, m);
	List<Termin> termine = qbe.execute();
	String fname = lFile.getText();
	if (fname.toLowerCase().endsWith(".csv")) { //$NON-NLS-1$
		new CSVExporter().doExport(fname, termine);
	} else {
		TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
		TimeZone timezone = registry.getTimeZone("Europe/Zurich"); //$NON-NLS-1$
		VTimeZone tz = timezone.getVTimeZone();
		Calendar calendar = new Calendar();
		calendar.getProperties().add(new ProdId("-//ch.elexis//Elexis v" + CoreHub.Version)); //$NON-NLS-1$
		calendar.getProperties().add(Version.VERSION_2_0);
		calendar.getProperties().add(CalScale.GREGORIAN);
		for (Termin t : termine) {
			if ((t.getStartMinute() == 0) && (t.getType().equals(Termin.typReserviert()))) {
				continue;
			}
			if ((t.getStartMinute() + t.getDurationInMinutes() == (23 * 60) + 59)
				&& (t.getType().equals(Termin.typReserviert()))) {
				continue;
			}
			TimeTool tt = new TimeTool(t.getStartTime());
			DateTime start = new DateTime(tt.getTime());
			tt.addMinutes(t.getDurationInMinutes());
			DateTime end = new DateTime(tt.getTime());
			VEvent vTermin = new VEvent(start, end, t.getPersonalia());
			vTermin.getProperties().add(tz.getTimeZoneId());
			Uid uid = new Uid(t.getId());
			vTermin.getProperties().add(uid);
			Description desc = new Description(t.getGrund());
			vTermin.getProperties().add(desc);
			calendar.getComponents().add(vTermin);
		}
		try {
			FileOutputStream fout = new FileOutputStream(lFile.getText());
			CalendarOutputter outputter = new CalendarOutputter();
			outputter.output(calendar, fout);
			
		} catch (Exception ex) {
			ExHandler.handle(ex);
			SWTHelper.alert(
				Messages.ICalTransfer_iOError,
				MessageFormat.format(Messages.ICalTransfer_couldNotWriteFile,
					lFile.getText()));
		}
	}
	super.okPressed();
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:56,代码来源:ICalTransfer.java


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