public class DateStart extends DateOrDateTimeProperty
Defines the start date of an event, free/busy component, or timezone component.
Code sample (creating):
VEvent event = new VEvent(); //date and time Date datetime = ... DateStart dtstart = new DateStart(datetime); event.setDateStart(dtstart); //date (without time component) Date date = ... dtstart = new DateStart(date, false); event.setDateStart(dtstart);Code sample (reading):
ICalendar ical = ...
for (VEvent event : ical.getEvents()){
DateStart dtstart = event.getDateStart();
//get property value (ICalDate extends java.util.Date)
ICalDate value = dtstart.getValue();
if (value.hasTime()){
//the value includes a time component
} else {
//the value is just a date
//date object's time is set to "00:00:00" under local computer's default timezone
}
//gets the timezone that the property value was parsed under if you are curious about that
TimeZone tz = tzinfo.getTimeZone(dtstart);
}
Code sample (using timezones):
DateStart dtstart = new DateStart(...); ICalendar ical = new ICalendar(); VEvent event = new VEvent(); event.setDateStart(dtstart); ical.addEvent(event); java.util.TimeZone tz = ... ICalWriter writer = new ICalWriter(...); //set the timezone of all date-time property values //date-time property values are written in UTC by default writer.getTimezoneInfo().setDefaultTimeZone(tz); //set the timezone just for this property writer.getTimezoneInfo().setTimeZone(dtstart, tz); //finally, write the iCalendar object writer.write(ical);
valueparameters| Constructor and Description |
|---|
DateStart(Date startDate)
Creates a start date property.
|
DateStart(Date startDate,
boolean hasTime)
Creates a start date property.
|
DateStart(ICalDate startDate)
Creates a start date property.
|
setValuegetValue, getValue, setValue, validateaddParameter, getParameter, getParameters, getParameters, removeParameter, setParameter, setParameter, setParameters, validatepublic DateStart(Date startDate)
startDate - the start datepublic DateStart(Date startDate, boolean hasTime)
startDate - the start datehasTime - true if the value has a time component, false if it is
strictly a dateCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.