001package biweekly.property;
002
003import java.util.Date;
004
005import biweekly.util.ICalDate;
006
007/*
008 Copyright (c) 2013-2015, Michael Angstadt
009 All rights reserved.
010
011 Redistribution and use in source and binary forms, with or without
012 modification, are permitted provided that the following conditions are met: 
013
014 1. Redistributions of source code must retain the above copyright notice, this
015 list of conditions and the following disclaimer. 
016 2. Redistributions in binary form must reproduce the above copyright notice,
017 this list of conditions and the following disclaimer in the documentation
018 and/or other materials provided with the distribution. 
019
020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
023 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
024 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
025 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
026 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
027 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
029 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030 */
031
032/**
033 * <p>
034 * Defines the start date of an event, free/busy component, or timezone
035 * component.
036 * </p>
037 * 
038 * <p>
039 * <b>Code sample (creating):</b>
040 * 
041 * <pre class="brush:java">
042 * VEvent event = new VEvent();
043 * 
044 * //date and time
045 * Date datetime = ...
046 * DateStart dtstart = new DateStart(datetime);
047 * event.setDateStart(dtstart);
048 * 
049 * //date (without time component)
050 * Date date = ...
051 * dtstart = new DateStart(date, false);
052 * event.setDateStart(dtstart);
053 * </pre>
054 * 
055 * </p>
056 * 
057 * <b>Code sample (reading):</b>
058 * 
059 * <pre class="brush:java">
060 * ICalendar ical = ...
061 * for (VEvent event : ical.getEvents()){
062 *   DateStart dtstart = event.getDateStart();
063 *   
064 *   //get property value (ICalDate extends java.util.Date)
065 *   ICalDate value = dtstart.getValue();
066 *   
067 *   if (value.hasTime()){
068 *     //the value includes a time component
069 *   } else {
070 *     //the value is just a date
071 *     //date object's time is set to "00:00:00" under local computer's default timezone
072 *   }
073 *   
074 *   //gets the timezone that the property value was parsed under if you are curious about that
075 *   TimeZone tz = tzinfo.getTimeZone(dtstart);
076 * }
077 * </pre>
078 * 
079 * </p>
080 * 
081 * <p>
082 * <b>Code sample (using timezones):</b>
083 * 
084 * <pre class="brush:java">
085 * DateStart dtstart = new DateStart(...);
086 * 
087 * ICalendar ical = new ICalendar();
088 * VEvent event = new VEvent();
089 * event.setDateStart(dtstart);
090 * ical.addEvent(event);
091 * 
092 * java.util.TimeZone tz = ...
093 * ICalWriter writer = new ICalWriter(...);
094 * 
095 * //set the timezone of all date-time property values
096 * //date-time property values are written in UTC by default
097 * writer.getTimezoneInfo().setDefaultTimeZone(tz);
098 * 
099 * //set the timezone just for this property
100 * writer.getTimezoneInfo().setTimeZone(dtstart, tz);
101 * 
102 * //finally, write the iCalendar object
103 * writer.write(ical);
104 * </pre>
105 * 
106 * </p>
107 * @author Michael Angstadt
108 * @see <a href="http://tools.ietf.org/html/rfc5545#page-97">RFC 5545 p.97-8</a>
109 * @see <a href="http://tools.ietf.org/html/rfc2445#page-93">RFC 2445 p.93-4</a>
110 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.35</a>
111 */
112public class DateStart extends DateOrDateTimeProperty {
113        /**
114         * Creates a start date property.
115         * @param startDate the start date
116         */
117        public DateStart(Date startDate) {
118                super(startDate);
119        }
120
121        /**
122         * Creates a start date property.
123         * @param startDate the start date
124         * @param hasTime true if the value has a time component, false if it is
125         * strictly a date
126         */
127        public DateStart(Date startDate, boolean hasTime) {
128                super(startDate, hasTime);
129        }
130
131        /**
132         * Creates a start date property.
133         * @param startDate the start date
134         */
135        public DateStart(ICalDate startDate) {
136                super(startDate);
137        }
138}