本文整理汇总了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();
}
示例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;
}
示例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);
}
}
示例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)
}
}
}
示例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;
}
示例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();
}