public class DateDue extends DateOrDateTimeProperty
Defines the due date of a to-do task.
Code sample (creating):
VTodo todo = new VTodo();
//date and time
Date datetime = ...
DateDue due = new DateDue(datetime);
todo.setDateDue(due);
//date (without time component)
Date date = ...
due = new DateDue(date, false);
todo.setDateDue(due);
//date and time with timezone (Date object converted to the specified timezone when writing the iCalendar object)
Date datetime = ...
due = new DateDue(datetime);
due.setTimezoneId("America/New_York");
todo.setDateDue(due);
//raw date/time components
DateTimeComponents components = new DateTimeComponents(1999, 4, 4, 2, 0, 0, false);
due = new DateDue(components);
todo.setDateDue(due);
Code sample (retrieving):
ICalendar ical = ...
for (VTodo todo : ical.getTodos()){
DateDue due = todo.getDateDue();
//get the raw date/time components from the date string
DateTimeComponents components = due.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 = due.getValue();
if (due.hasTime()){
//the value includes a time component
if (due.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 |
|---|
DateDue(Date dueDate)
Creates a due date property.
|
DateDue(Date dueDate,
boolean hasTime)
Creates a due date property.
|
DateDue(DateTimeComponents components)
Creates an due date property.
|
getRawComponents, getTimezoneId, getValue, hasTime, isLocalTime, setLocalTime, setRawComponents, setTimezone, setTimezoneId, setValue, validateaddParameter, getParameter, getParameters, getParameters, removeParameter, setParameter, setParameter, setParameters, validatepublic DateDue(Date dueDate, boolean hasTime)
dueDate - the due datehasTime - true to include the time component of the date, false not
topublic DateDue(DateTimeComponents components)
components - the raw components of the date-time valueCopyright © 2013-2014 Michael Angstadt. All Rights Reserved.