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); //date and time with timezone (Date object converted to the specified timezone when writing the iCalendar object) Date datetime = ... dtstart = new DateStart(datetime); dtstart.setTimezoneId("America/New_York"); event.setDateStart(dtstart); //raw date/time components DateTimeComponents components = new DateTimeComponents(1999, 4, 4, 2, 0, 0, false); dtstart = new DateStart(components); event.setDateStart(dtstart);Code sample (retrieving):
ICalendar ical = ... for (VEvent event : ical.getEvents()){ DateStart dtstart = event.getDateStart(); //get the raw date/time components from the date string DateTimeComponents components = dtstart.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 = dtstart.getValue(); if (dtstart.hasTime()){ //the value includes a time component if (dtstart.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, value
parameters
Constructor and Description |
---|
DateStart(Date startDate)
Creates a start date property.
|
DateStart(Date startDate,
boolean hasTime)
Creates a start date property.
|
DateStart(DateTimeComponents components)
Creates a start date property.
|
getRawComponents, getTimezoneId, getValue, hasTime, isLocalTime, setLocalTime, setRawComponents, setTimezone, setTimezoneId, setValue, validate
addParameter, getParameter, getParameters, getParameters, removeParameter, setParameter, setParameter, setParameters, validate
public DateStart(Date startDate)
startDate
- the start datepublic DateStart(Date startDate, boolean hasTime)
startDate
- the start datehasTime
- true to include the time component of the date, false not
topublic DateStart(DateTimeComponents components)
components
- the raw components of the date-time valueCopyright © 2013-2014 Michael Angstadt. All Rights Reserved.