public class DateEnd extends DateOrDateTimeProperty
Defines the end date of an event or free/busy component.
Code sample (creating):
VEvent event = new VEvent();
//date and time
Date datetime = ...
DateEnd dtend = new DateEnd(datetime);
event.setDateEnd(dtend);
//date (without time component)
Date date = ...
dtend = new DateEnd(date, false);
event.setDateEnd(dtend);
//date and time with timezone (Date object converted to the specified timezone when writing the iCalendar object)
Date datetime = ...
dtend = new DateEnd(datetime);
dtend.setTimezoneId("America/New_York");
event.setDateEnd(dtend);
//raw date/time components
DateTimeComponents components = new DateTimeComponents(1999, 4, 4, 2, 0, 0, false);
dtend = new DateEnd(components);
event.setDateEnd(dtend);
Code sample (retrieving):
ICalendar ical = ...
for (VEvent event : ical.getEvents()){
DateEnd dtend = event.getDateEnd();
//get the raw date/time components from the date string
DateTimeComponents components = dtend.getRawComponents();
int year = components.getYear();
int month = components.getMonth();
//etc.
//get the Java Date object that was generated based on the provided timezone
Date value = dtend.getValue();
if (dtend.hasTime()){
//the value includes a time component
if (dtend.isLocalTime()){
//timezone information was not provided
//Java Date object was parsed under the local computer's default timezone
} else {
//timezone information was provided
//Java Date object was parsed under the provided timezone (if recognized)
}
} else {
//the value is just a date
//Java Date object's time is set to "00:00:00" under the local computer's default timezone
}
}
hasTime, localTime, rawComponents, valueparameters| Constructor and Description |
|---|
DateEnd(Date endDate)
Creates an end date property.
|
DateEnd(Date endDate,
boolean hasTime)
Creates an end date property.
|
DateEnd(DateTimeComponents components)
Creates an end date property.
|
getRawComponents, getTimezoneId, getValue, hasTime, isLocalTime, setLocalTime, setRawComponents, setTimezone, setTimezoneId, setValue, validateaddParameter, getParameter, getParameters, getParameters, removeParameter, setParameter, setParameter, setParameters, validatepublic DateEnd(Date endDate)
endDate - the end datepublic DateEnd(Date endDate, boolean hasTime)
endDate - the end datehasTime - true to include the time component of the date, false not
topublic DateEnd(DateTimeComponents components)
components - the raw components of the date-time valueCopyright © 2013-2014 Michael Angstadt. All Rights Reserved.