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