forked from ical4j/ical4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.jpage
81 lines (57 loc) · 3.94 KB
/
examples.jpage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// create timezone property..
java.util.TimeZone timezone = java.util.TimeZone.getDefault();
net.fortuna.ical4j.model.property.TzName standardTzName = new net.fortuna.ical4j.model.property.TzName(new net.fortuna.ical4j.model.ParameterList(), timezone.getDisplayName());
net.fortuna.ical4j.model.property.DtStart standardTzStart = new net.fortuna.ical4j.model.property.DtStart(new net.fortuna.ical4j.model.ParameterList(), new java.util.Date());
net.fortuna.ical4j.model.property.TzOffsetTo standardTzOffsetTo = new net.fortuna.ical4j.model.property.TzOffsetTo(new net.fortuna.ical4j.model.ParameterList(), timezone.getRawOffset());
// "offset to" plus one (1) hour??
long millisPerHour = 1000 * 60 * 60;
net.fortuna.ical4j.model.property.TzOffsetFrom standardTzOffsetFrom = new net.fortuna.ical4j.model.property.TzOffsetFrom(null, timezone.getRawOffset() + millisPerHour);
net.fortuna.ical4j.model.PropertyList standardTzProps = new net.fortuna.ical4j.model.PropertyList();
standardTzProps.add(standardTzName);
standardTzProps.add(standardTzStart);
standardTzProps.add(standardTzOffsetTo);
standardTzProps.add(standardTzOffsetFrom);
net.fortuna.ical4j.model.component.Standard standardTz = new net.fortuna.ical4j.model.component.Standard(standardTzProps);
net.fortuna.ical4j.model.property.TzId tzId = new net.fortuna.ical4j.model.property.TzId(null, timezone.getID());
net.fortuna.ical4j.model.PropertyList tzProps = new net.fortuna.ical4j.model.PropertyList();
tzProps.add(tzId);
net.fortuna.ical4j.model.ComponentList tzComponents = new net.fortuna.ical4j.model.ComponentList();
tzComponents.add(standardTz);
net.fortuna.ical4j.model.component.VTimeZone tz = new net.fortuna.ical4j.model.component.VTimeZone(tzProps, tzComponents);
net.fortuna.ical4j.model.component.VTimeZone tz = net.fortuna.ical4j.model.component.VTimeZone.getDefault();
tz.validate();
net.fortuna.ical4j.util.TimeZoneUtils.getDaylightStart(java.util.TimeZone.getDefault());
net.fortuna.ical4j.util.TimeZoneUtils.getDaylightEnd(java.util.TimeZone.getDefault());
// create tzid parameter..
net.fortuna.ical4j.model.parameter.TzId tzParam = new net.fortuna.ical4j.model.parameter.TzId(timezone.getID());
// create value parameter..
net.fortuna.ical4j.model.parameter.Value type = new net.fortuna.ical4j.model.parameter.Value(net.fortuna.ical4j.model.parameter.Value.DATE);
net.fortuna.ical4j.model.ParameterList params = new net.fortuna.ical4j.model.ParameterList();
params.add(tzParam);
params.add(type);
// create event start date..
java.util.Calendar calendar = java.util.Calendar.getInstance();
calendar.set(java.util.Calendar.MONTH, java.util.Calendar.DECEMBER);
calendar.set(java.util.Calendar.DAY_OF_MONTH, 25);
net.fortuna.ical4j.model.property.DtStart start = new net.fortuna.ical4j.model.property.DtStart(params, calendar.getTime());
net.fortuna.ical4j.model.property.Summary summary = new net.fortuna.ical4j.model.property.Summary(null, "Christmas Day");
net.fortuna.ical4j.model.PropertyList properties = new net.fortuna.ical4j.model.PropertyList();
properties.add(start);
properties.add(summary);
net.fortuna.ical4j.model.component.VEvent christmas = new net.fortuna.ical4j.model.component.VEvent(properties);
// create a period..
net.fortuna.ical4j.model.property.RDate recDate = null;
net.fortuna.ical4j.model.Period period = null;
net.fortuna.ical4j.model.PeriodList periods = new net.fortuna.ical4j.model.PeriodList();
period = new net.fortuna.ical4j.model.Period("20050303T090301Z/20050604T090301Z");
periods.add(period);
recDate = new net.fortuna.ical4j.model.property.RDate(new net.fortuna.ical4j.model.ParameterList(),periods);
recDate
// Test string escaping..
String value = "Churchill delivers his \"Iron Curtain\" speech\, 1947";
return net.fortuna.ical4j.util.Strings.unescape(value);
String UTC_PATTERN = "yyyyMMdd'T'HHmmss'Z'";
String DEFAULT_PATTERN = "yyyyMMdd'T'HHmmss";
java.text.DateFormat df = new java.text.SimpleDateFormat(DEFAULT_PATTERN);
df.setLenient(false);
return df.parse("20030731T230000");