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 due date of a to-do task.
035 * </p>
036 * 
037 * <p>
038 * <b>Code sample (creating):</b>
039 * 
040 * <pre class="brush:java">
041 * VTodo todo = new VTodo();
042 * 
043 * //date and time
044 * Date datetime = ...
045 * DateDue due = new DateDue(datetime);
046 * todo.setDateDue(due);
047 * 
048 * //date (without time component)
049 * Date date = ...
050 * due = new DateDue(date, false);
051 * todo.setDateDue(due);
052 * </pre>
053 * 
054 * </p>
055 * 
056 * <b>Code sample (reading):</b>
057 * 
058 * <pre class="brush:java">
059 * ICalReader reader = ...
060 * ICalendar ical = reader.readNext();
061 * TimezoneInfo tzinfo = reader.getTimezoneInfo();
062 * 
063 * for (VTodo todo : ical.getTodos()){
064 *   DateDue due = todo.getDateDue();
065 *   
066 *   //get property value (ICalDate extends java.util.Date)
067 *   ICalDate value = due.getValue();
068 *   
069 *   if (value.hasTime()){
070 *     //the value includes a time component
071 *   } else {
072 *     //the value is just a date
073 *     //date object's time is set to "00:00:00" under local computer's default timezone
074 *   }
075 *   
076 *   //gets the timezone that the property value was parsed under if you are curious about that
077 *   TimeZone tz = tzinfo.getTimeZone(due);
078 * }
079 * </pre>
080 * 
081 * </p>
082 * 
083 * <p>
084 * <b>Code sample (using timezones):</b>
085 * 
086 * <pre class="brush:java">
087 * DateDue due = new DateDue(...);
088 * 
089 * ICalendar ical = new ICalendar();
090 * VTodo todo = new VTodo();
091 * Date datetime = ...
092 * todo.setDateDue(due);
093 * ical.addTodo(todo);
094 * 
095 * java.util.TimeZone tz = ...
096 * ICalWriter writer = new ICalWriter(...);
097 * 
098 * //set the timezone of all date-time property values
099 * //date-time property values are written in UTC by default
100 * writer.getTimezoneInfo().setDefaultTimeZone(tz);
101 * 
102 * //set the timezone just for this property
103 * writer.getTimezoneInfo().setTimeZone(due, tz);
104 * 
105 * //finally, write the iCalendar object
106 * writer.write(ical);
107 * </pre>
108 * 
109 * </p>
110 * @author Michael Angstadt
111 * @see <a href="http://tools.ietf.org/html/rfc5545#page-96">RFC 5545 p.96-7</a>
112 * @see <a href="http://tools.ietf.org/html/rfc2445#page-92">RFC 2445 p.92-3</a>
113 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.30</a>
114 */
115public class DateDue extends DateOrDateTimeProperty {
116        /**
117         * Creates a due date property.
118         * @param dueDate the due date
119         */
120        public DateDue(Date dueDate) {
121                super(dueDate);
122        }
123
124        /**
125         * Creates a due date property.
126         * @param dueDate the due date
127         * @param hasTime true if the value has a time component, false if it is
128         * strictly a date
129         */
130        public DateDue(Date dueDate, boolean hasTime) {
131                super(dueDate, hasTime);
132        }
133
134        /**
135         * Creates a due date property.
136         * @param dueDate the due date
137         */
138        public DateDue(ICalDate dueDate) {
139                super(dueDate);
140        }
141}