1.1 --- a/src/net/fortuna/ical4j/model/Date.java Thu Feb 12 18:02:00 2015 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,176 +0,0 @@ 1.4 -/** 1.5 - * Copyright (c) 2012, Ben Fortuna 1.6 - * All rights reserved. 1.7 - * 1.8 - * Redistribution and use in source and binary forms, with or without 1.9 - * modification, are permitted provided that the following conditions 1.10 - * are met: 1.11 - * 1.12 - * o Redistributions of source code must retain the above copyright 1.13 - * notice, this list of conditions and the following disclaimer. 1.14 - * 1.15 - * o Redistributions in binary form must reproduce the above copyright 1.16 - * notice, this list of conditions and the following disclaimer in the 1.17 - * documentation and/or other materials provided with the distribution. 1.18 - * 1.19 - * o Neither the name of Ben Fortuna nor the names of any other contributors 1.20 - * may be used to endorse or promote products derived from this software 1.21 - * without specific prior written permission. 1.22 - * 1.23 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.24 - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.25 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.26 - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 1.27 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.28 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.29 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.30 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.31 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.32 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.33 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.34 - */ 1.35 -package net.fortuna.ical4j.model; 1.36 - 1.37 -import java.text.DateFormat; 1.38 -import java.text.ParseException; 1.39 -import java.text.SimpleDateFormat; 1.40 -import java.util.TimeZone; 1.41 - 1.42 -import net.fortuna.ical4j.util.CompatibilityHints; 1.43 -import net.fortuna.ical4j.util.Dates; 1.44 -import net.fortuna.ical4j.util.TimeZones; 1.45 - 1.46 - 1.47 -/** 1.48 - * $Id$ 1.49 - * 1.50 - * Created on 26/06/2005 1.51 - * 1.52 - * Base class for all representations of time values in RFC2445. 1.53 - * 1.54 - * <pre> 1.55 - * 4.3.4 Date 1.56 - * 1.57 - * Value Name: DATE 1.58 - * 1.59 - * Purpose: This value type is used to identify values that contain a 1.60 - * calendar date. 1.61 - * 1.62 - * Formal Definition: The value type is defined by the following 1.63 - * notation: 1.64 - * 1.65 - * date = date-value 1.66 - * 1.67 - * date-value = date-fullyear date-month date-mday 1.68 - * date-fullyear = 4DIGIT 1.69 - * date-month = 2DIGIT ;01-12 1.70 - * date-mday = 2DIGIT ;01-28, 01-29, 01-30, 01-31 1.71 - * ;based on month/year 1.72 - * 1.73 - * Description: If the property permits, multiple "date" values are 1.74 - * specified as a COMMA character (US-ASCII decimal 44) separated list 1.75 - * of values. The format for the value type is expressed as the [ISO 1.76 - * 8601] complete representation, basic format for a calendar date. The 1.77 - * textual format specifies a four-digit year, two-digit month, and 1.78 - * two-digit day of the month. There are no separator characters between 1.79 - * the year, month and day component text. 1.80 - * 1.81 - * No additional content value encoding (i.e., BACKSLASH character 1.82 - * encoding) is defined for this value type. 1.83 - * 1.84 - * Example: The following represents July 14, 1997: 1.85 - * 1.86 - * 19970714 1.87 - * 1.88 - * </pre> 1.89 - * 1.90 - * @author Ben Fortuna 1.91 - */ 1.92 -public class Date extends Iso8601 { 1.93 - 1.94 - private static final long serialVersionUID = 7136072363141363141L; 1.95 - 1.96 - private static final String DEFAULT_PATTERN = "yyyyMMdd"; 1.97 - 1.98 - private static final String VCARD_PATTERN = "yyyy'-'MM'-'dd"; 1.99 - 1.100 - /** 1.101 - * Default constructor. 1.102 - */ 1.103 - public Date() { 1.104 - super(DEFAULT_PATTERN, Dates.PRECISION_DAY, TimeZones.getDateTimeZone()); 1.105 - } 1.106 - 1.107 - /** 1.108 - * Creates a new date instance with the specified precision. This 1.109 - * constructor is only intended for use by sub-classes. 1.110 - * @param precision the date precision 1.111 - * @param tz the timezone 1.112 - * @see Dates#PRECISION_DAY 1.113 - * @see Dates#PRECISION_SECOND 1.114 - */ 1.115 - protected Date(final int precision, TimeZone tz) { 1.116 - super(DEFAULT_PATTERN, precision, tz); 1.117 - } 1.118 - 1.119 - /** 1.120 - * @param time a date value in milliseconds 1.121 - */ 1.122 - public Date(final long time) { 1.123 - super(time, DEFAULT_PATTERN, Dates.PRECISION_DAY, TimeZones.getDateTimeZone()); 1.124 - } 1.125 - 1.126 - /** 1.127 - * Creates a new date instance with the specified precision. This 1.128 - * constructor is only intended for use by sub-classes. 1.129 - * @param time a date value in milliseconds 1.130 - * @param precision the date precision 1.131 - * @param tz the timezone 1.132 - * @see Dates#PRECISION_DAY 1.133 - * @see Dates#PRECISION_SECOND 1.134 - */ 1.135 - protected Date(final long time, final int precision, TimeZone tz) { 1.136 - super(time, DEFAULT_PATTERN, precision, tz); 1.137 - } 1.138 - 1.139 - /** 1.140 - * @param date a date value 1.141 - */ 1.142 - public Date(final java.util.Date date) { 1.143 -// this(); 1.144 - this(date.getTime(), Dates.PRECISION_DAY, TimeZones.getDateTimeZone()); 1.145 -// setTime(date.getTime()); 1.146 - } 1.147 - 1.148 - /** 1.149 - * @param value a string representation of a date 1.150 - * @throws ParseException where the specified string is not a valid date 1.151 - */ 1.152 - public Date(final String value) throws ParseException { 1.153 - this(); 1.154 - try { 1.155 - setTime(getFormat().parse(value).getTime()); 1.156 - } catch (ParseException pe) { 1.157 - if (CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_VCARD_COMPATIBILITY)) { 1.158 - final DateFormat parseFormat = new SimpleDateFormat(VCARD_PATTERN); 1.159 - parseFormat.setTimeZone(TimeZones.getDateTimeZone()); 1.160 - setTime(parseFormat.parse(value).getTime()); 1.161 - } 1.162 - else { 1.163 - throw pe; 1.164 - } 1.165 - } 1.166 - } 1.167 - 1.168 - /** 1.169 - * @param value a string representation of a date 1.170 - * @param pattern a date pattern to apply when parsing 1.171 - * @throws ParseException where the specified string is not a valid date 1.172 - */ 1.173 - public Date(String value, String pattern) throws ParseException { 1.174 - super(DEFAULT_PATTERN, Dates.PRECISION_DAY, TimeZones.getDateTimeZone()); 1.175 - final DateFormat parseFormat = new SimpleDateFormat(pattern); 1.176 - parseFormat.setTimeZone(TimeZones.getDateTimeZone()); 1.177 - setTime(parseFormat.parse(value).getTime()); 1.178 - } 1.179 -}