本文整理汇总了Java中biweekly.io.TimezoneAssignment类的典型用法代码示例。如果您正苦于以下问题:Java TimezoneAssignment类的具体用法?Java TimezoneAssignment怎么用?Java TimezoneAssignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimezoneAssignment类属于biweekly.io包,在下文中一共展示了TimezoneAssignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: americaNewYorkWithoutDaylight
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
private TimezoneInfo americaNewYorkWithoutDaylight() {
VTimezone timezone = new VTimezone("id");
{
StandardTime standard = new StandardTime();
standard.setDateStart(new DateTimeComponents(2007, 11, 4, 2, 0, 0, false));
standard.setTimezoneOffsetFrom(new UtcOffset(false, 4, 0));
standard.setTimezoneOffsetTo(new UtcOffset(false, 5, 0));
standard.addTimezoneName("EST");
//@formatter:off
standard.setRecurrenceRule(new Recurrence.Builder
(Frequency.YEARLY)
.byMonth(11)
.byDay(1, DayOfWeek.SUNDAY)
.build());
//@formatter:on
timezone.addStandardTime(standard);
}
ICalTimeZone icalTz = new ICalTimeZone(timezone);
TimezoneInfo tzinfo = new TimezoneInfo();
tzinfo.setDefaultTimezone(new TimezoneAssignment(icalTz, timezone));
return tzinfo;
}
示例2: getTimeZoneStart
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
private TimeZone getTimeZoneStart(ICalendar ical, VEvent event) {
if (event.getDateStart() == null) {
return null;
}
TimezoneInfo tzinfo = ical.getTimezoneInfo();
TimeZone timezone;
if (tzinfo.isFloating(event.getDateStart())) {
timezone = TimeZone.getDefault();
} else {
TimezoneAssignment dtstartTimezone = tzinfo.getTimezone(event.getDateStart());
timezone = (dtstartTimezone == null) ? TimeZone.getTimeZone("UTC") : dtstartTimezone.getTimeZone();
}
return timezone;
}
示例3: americaNewYork
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
private static TimezoneInfo americaNewYork() {
String id = "America/New_York";
TimeZone timezone = TimeZone.getTimeZone(id);
VTimezone component = new VTimezone(id);
TimezoneInfo tzinfo = new TimezoneInfo();
tzinfo.setDefaultTimezone(new TimezoneAssignment(timezone, component));
return tzinfo;
}
示例4: americaNewYork
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
private TimezoneInfo americaNewYork() {
VTimezone timezone = new VTimezone("id");
{
DaylightSavingsTime daylightSavings = new DaylightSavingsTime();
daylightSavings.setDateStart(new DateTimeComponents(2007, 3, 11, 2, 0, 0, false));
daylightSavings.setTimezoneOffsetFrom(new UtcOffset(false, 5, 0));
daylightSavings.setTimezoneOffsetTo(new UtcOffset(false, 4, 0));
daylightSavings.addTimezoneName("EDT");
//@formatter:off
daylightSavings.setRecurrenceRule(new Recurrence.Builder
(Frequency.YEARLY)
.byMonth(3)
.byDay(2, DayOfWeek.SUNDAY)
.build());
//@formatter:on
timezone.addDaylightSavingsTime(daylightSavings);
StandardTime standard = new StandardTime();
standard.setDateStart(new DateTimeComponents(2007, 11, 4, 2, 0, 0, false));
standard.setTimezoneOffsetFrom(new UtcOffset(false, 4, 0));
standard.setTimezoneOffsetTo(new UtcOffset(false, 5, 0));
standard.addTimezoneName("EST");
//@formatter:off
standard.setRecurrenceRule(new Recurrence.Builder
(Frequency.YEARLY)
.byMonth(11)
.byDay(1, DayOfWeek.SUNDAY)
.build());
//@formatter:on
timezone.addStandardTime(standard);
}
ICalTimeZone icalTz = new ICalTimeZone(timezone);
TimezoneInfo tzinfo = new TimezoneInfo();
tzinfo.setDefaultTimezone(new TimezoneAssignment(icalTz, timezone));
return tzinfo;
}
示例5: handleTzidParameter
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
/**
* Adds a TZID parameter to a property's parameter list if necessary.
* @param property the property
* @param hasTime true if the property value has a time component, false if
* not
* @param context the write context
* @return the property's new set of parameters
*/
protected static ICalParameters handleTzidParameter(ICalProperty property, boolean hasTime, WriteContext context) {
ICalParameters parameters = property.getParameters();
//date values don't have timezones
if (!hasTime) {
return parameters;
}
//vCal doesn't use the TZID parameter
if (context.getVersion() == ICalVersion.V1_0) {
return parameters;
}
//floating values don't have timezones
TimezoneInfo tzinfo = context.getTimezoneInfo();
boolean floating = tzinfo.isFloating(property);
if (floating) {
return parameters;
}
TimezoneAssignment tz;
TimezoneAssignment globalTz = context.getGlobalTimezone();
if (globalTz == null) {
tz = tzinfo.getTimezoneToWriteIn(property);
if (tz == null) {
//write in UTC
return parameters;
}
} else {
tz = globalTz;
}
String tzid = null;
VTimezone component = tz.getComponent();
String globalId = tz.getGlobalId();
if (component != null) {
tzid = ValuedProperty.getValue(component.getTimezoneId());
} else if (globalId != null) {
tzid = '/' + globalId;
}
if (tzid == null) {
//should never happen
tzid = tz.getTimeZone().getID();
}
parameters = new ICalParameters(parameters);
parameters.setTimezoneId(tzid);
return parameters;
}
示例6: globalTz
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
public U globalTz(TimezoneAssignment globalTimeZone) {
this.globalTimeZone = globalTimeZone;
return this_;
}
示例7: setGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
@Test
public void setGlobalTimezone() throws Throwable {
ICalendar ical = new ICalendar();
ical.getProperties().clear();
VEvent event = new VEvent();
event.getProperties().clear();
event.setDateStart(utc("1996-07-04 12:00:00"));
ical.addEvent(event);
TimeZone nyTimezone = TimeZone.getTimeZone("America/New_York");
VTimezone nyComponent = new VTimezone(nyTimezone.getID());
ical.getTimezoneInfo().setDefaultTimezone(new TimezoneAssignment(nyTimezone, nyComponent));
TimeZone laTimezone = TimeZone.getTimeZone("America/Los_Angeles");
VTimezone laComponent = new VTimezone(laTimezone.getID());
StringWriter sw = new StringWriter();
JCalWriter writer = new JCalWriter(sw, true);
writer.write(ical);
writer.setGlobalTimezone(new TimezoneAssignment(laTimezone, laComponent));
writer.write(ical);
writer.close();
//@formatter:off
String expected =
"[[\"vcalendar\"," +
"[" +
"[\"version\",{},\"text\",\"2.0\"]" +
"]," +
"[" +
"[\"vtimezone\"," +
"[" +
"[\"tzid\",{},\"text\",\"America/New_York\"]" +
"]," +
"[]" +
"]," +
"[\"vevent\"," +
"[" +
"[\"dtstart\",{\"tzid\":\"America/New_York\"},\"date-time\",\"1996-07-04T08:00:00\"]" +
"]," +
"[]" +
"]" +
"]" +
"]," +
"[\"vcalendar\"," +
"[" +
"[\"version\",{},\"text\",\"2.0\"]" +
"]," +
"[" +
"[\"vtimezone\"," +
"[" +
"[\"tzid\",{},\"text\",\"America/Los_Angeles\"]" +
"]," +
"[]" +
"]," +
"[\"vevent\"," +
"[" +
"[\"dtstart\",{\"tzid\":\"America/Los_Angeles\"},\"date-time\",\"1996-07-04T05:00:00\"]" +
"]," +
"[]" +
"]" +
"]" +
"]]";
//@formatter:on
String actual = sw.toString();
assertEquals(expected, actual);
}
示例8: setGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
@Test
public void setGlobalTimezone() throws Throwable {
ICalendar ical = new ICalendar();
ical.getProperties().clear();
VEvent event = new VEvent();
event.getProperties().clear();
event.setDateStart(utc("1996-07-04 12:00:00"));
ical.addEvent(event);
TimeZone nyTimezone = TimeZone.getTimeZone("America/New_York");
VTimezone nyComponent = new VTimezone(nyTimezone.getID());
ical.getTimezoneInfo().setDefaultTimezone(new TimezoneAssignment(nyTimezone, nyComponent));
TimeZone laTimezone = TimeZone.getTimeZone("America/Los_Angeles");
VTimezone laComponent = new VTimezone(laTimezone.getID());
StringWriter sw = new StringWriter();
ICalWriter writer = new ICalWriter(sw, V2_0);
writer.write(ical);
writer.setGlobalTimezone(new TimezoneAssignment(laTimezone, laComponent));
writer.write(ical);
writer.close();
//@formatter:off
String expected =
"BEGIN:VCALENDAR\r\n" +
"VERSION:2.0\r\n" +
"BEGIN:VTIMEZONE\r\n" +
"TZID:America/New_York\r\n" +
"END:VTIMEZONE\r\n" +
"BEGIN:VEVENT\r\n" +
"DTSTART;TZID=America/New_York:19960704T080000\r\n" +
"END:VEVENT\r\n" +
"END:VCALENDAR\r\n" +
"BEGIN:VCALENDAR\r\n" +
"VERSION:2.0\r\n" +
"BEGIN:VTIMEZONE\r\n" +
"TZID:America/Los_Angeles\r\n" +
"END:VTIMEZONE\r\n" +
"BEGIN:VEVENT\r\n" +
"DTSTART;TZID=America/Los_Angeles:19960704T050000\r\n" +
"END:VEVENT\r\n" +
"END:VCALENDAR\r\n";
//@formatter:on
String actual = sw.toString();
assertEquals(expected, actual);
}
示例9: example2
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
@Test
public void example2() throws Throwable {
TimeZone eastern = TimeZone.getTimeZone("America/New_York");
ICalendar ical = new ICalendar();
ical.getProperties().clear();
ical.setProductId("-//RDU Software//NONSGML HandCal//EN");
{
VEvent event = new VEvent();
event.setDateTimeStamp(utc("1998-03-09 23:10:00"));
event.setUid("guid-1.example.com");
event.setOrganizer("[email protected]");
Attendee attendee = new Attendee(null, "[email protected]");
attendee.setRsvp(true);
attendee.setParticipationLevel(ParticipationLevel.REQUIRED);
attendee.setCalendarUserType(CalendarUserType.GROUP);
event.addAttendee(attendee);
event.setDescription("Project XYZ Review Meeting");
event.addCategories("MEETING");
event.setClassification(Classification.public_());
event.setCreated(utc("1998-03-09 13:00:00"));
event.setSummary("XYZ Project Review");
event.setDateStart(date("1998-03-12 08:30:00", eastern));
event.setDateEnd(date("1998-03-12 09:30:00", eastern));
event.setLocation("1CP Conference Room 4350");
ical.addEvent(event);
}
assertValidate(ical).versions(V2_0_DEPRECATED, V2_0).run();
TimezoneInfo tzinfo = ical.getTimezoneInfo();
VTimezone usEasternTz;
{
usEasternTz = new VTimezone("America/New_York");
{
StandardTime standard = new StandardTime();
standard.setDateStart(new DateTimeComponents(1998, 10, 25, 2, 0, 0, false));
standard.setTimezoneOffsetFrom(new UtcOffset(false, 4, 0));
standard.setTimezoneOffsetTo(new UtcOffset(false, 5, 0));
standard.addTimezoneName("EST");
usEasternTz.addStandardTime(standard);
}
{
DaylightSavingsTime daylight = new DaylightSavingsTime();
daylight.setDateStart(new DateTimeComponents(1999, 4, 4, 2, 0, 0, false));
daylight.setTimezoneOffsetFrom(new UtcOffset(false, 5, 0));
daylight.setTimezoneOffsetTo(new UtcOffset(false, 4, 0));
daylight.addTimezoneName("EDT");
usEasternTz.addDaylightSavingsTime(daylight);
}
}
tzinfo.setDefaultTimezone(new TimezoneAssignment(eastern, usEasternTz));
assertExample(ical, "rfc5545-example2.ics", V2_0);
}
示例10: setGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
@Test
public void setGlobalTimezone() throws Throwable {
VEvent event = new VEvent();
event.getProperties().clear();
event.setDateStart(utc("1996-07-04 12:00:00"));
ical.addEvent(event);
TimeZone nyTimezone = TimeZone.getTimeZone("America/New_York");
VTimezone nyComponent = new VTimezone(nyTimezone.getID());
ical.getTimezoneInfo().setDefaultTimezone(new TimezoneAssignment(nyTimezone, nyComponent));
TimeZone laTimezone = TimeZone.getTimeZone("America/Los_Angeles");
VTimezone laComponent = new VTimezone(laTimezone.getID());
writer.write(ical);
writer.setGlobalTimezone(new TimezoneAssignment(laTimezone, laComponent));
writer.write(ical);
writer.close();
//@formatter:off
String expected =
"<icalendar xmlns=\"" + XCAL_NS + "\">" +
"<vcalendar>" +
"<properties>" +
"<version><text>2.0</text></version>" +
"</properties>" +
"<components>" +
"<vtimezone>" +
"<properties>" +
"<tzid><text>America/New_York</text></tzid>" +
"</properties>" +
"</vtimezone>" +
"<vevent>" +
"<properties>" +
"<dtstart>" +
"<parameters>" +
"<tzid><text>America/New_York</text></tzid>" +
"</parameters>" +
"<date-time>1996-07-04T08:00:00</date-time>" +
"</dtstart>" +
"</properties>" +
"</vevent>" +
"</components>" +
"</vcalendar>" +
"<vcalendar>" +
"<properties>" +
"<version><text>2.0</text></version>" +
"</properties>" +
"<components>" +
"<vtimezone>" +
"<properties>" +
"<tzid><text>America/Los_Angeles</text></tzid>" +
"</properties>" +
"</vtimezone>" +
"<vevent>" +
"<properties>" +
"<dtstart>" +
"<parameters>" +
"<tzid><text>America/Los_Angeles</text></tzid>" +
"</parameters>" +
"<date-time>1996-07-04T05:00:00</date-time>" +
"</dtstart>" +
"</properties>" +
"</vevent>" +
"</components>" +
"</vcalendar>" +
"</icalendar>";
//@formatter:on
assertOutput(expected);
}
示例11: getGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
/**
* Gets the timezone that all date/time property values will be formatted
* in. If set, this setting will override the timezone information
* associated with each {@link ICalendar} object.
* @return the global timezone or null if not set (defaults to null)
*/
public TimezoneAssignment getGlobalTimezone() {
return globalTimezone;
}
示例12: setGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
/**
* Sets the timezone that all date/time property values will be formatted
* in. This is a convenience method that overrides the timezone information
* associated with each {@link ICalendar} object that is passed into this
* writer.
* @param globalTimezone the global timezone or null not to set a global
* timezone (defaults to null)
*/
public void setGlobalTimezone(TimezoneAssignment globalTimezone) {
this.globalTimezone = globalTimezone;
}
示例13: getGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
/**
* Gets the timezone that all date/time property values will be formatted
* in. If set, this setting will override the timezone information
* associated with each {@link ICalendar} object.
* @return the global timezone or null if not set (defaults to null)
*/
public TimezoneAssignment getGlobalTimezone() {
return serializer.getGlobalTimezone();
}
示例14: setGlobalTimezone
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
/**
* Sets the timezone that all date/time property values will be formatted
* in. This is a convenience method that overrides the timezone information
* associated with each {@link ICalendar} object that is passed into this
* writer.
* @param globalTimezone the global timezone or null not to set a global
* timezone (defaults to null)
*/
public void setGlobalTimezone(TimezoneAssignment globalTimezone) {
serializer.setGlobalTimezone(globalTimezone);
}
示例15: tz
import biweekly.io.TimezoneAssignment; //导入依赖的package包/类
/**
* <p>
* Sets the timezone to use when outputting date values (defaults to UTC).
* </p>
* <p>
* This method downloads an appropriate VTIMEZONE component from the <a
* href="http://www.tzurl.org">tzurl.org</a> website.
* </p>
* @param defaultTimeZone the default timezone or null for UTC
* @param outlookCompatible true to download a VTIMEZONE component that is
* tailored for Microsoft Outlook email clients, false to download a
* standards-based one
* @return this
* @throws IllegalArgumentException if an appropriate VTIMEZONE component
* cannot be found on the website
*/
T tz(TimeZone defaultTimeZone, boolean outlookCompatible) {
this.defaultTimeZone = (defaultTimeZone == null) ? null : TimezoneAssignment.download(defaultTimeZone, outlookCompatible);
return this_;
}