001 package ezvcard.types;
002
003 import java.util.Date;
004
005 import ezvcard.VCardVersion;
006
007 /*
008 Copyright (c) 2012, 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 The views and conclusions contained in the software and documentation are those
032 of the authors and should not be interpreted as representing official policies,
033 either expressed or implied, of the FreeBSD Project.
034 */
035
036 /**
037 * Defines the person's anniversary.
038 *
039 * <p>
040 * <b>Setting the anniversary</b>
041 * </p>
042 *
043 * <pre>
044 * VCard vcard = new VCard();
045 *
046 * //complete date
047 * Calendar c = Calendar.getInstance();
048 * c.set(Calendar.YEAR, 1986);
049 * c.set(Calendar.MONTH, Calendar.MARCH);
050 * c.set(Calendar.DAY_OF_MONTH, 21);
051 * AnniversaryType anniversary = new AnniversaryType();
052 * anniversary.setDate(c.getTime(), false);
053 * vcard.setAnniversary(anniversary);
054 *
055 * //reduced accuracy date (see RFC 6350 p.12-14 for examples)
056 * anniversary = new AnniversaryType();
057 * anniversary.setReducedAccuracyDate("--0321"); //March 21
058 * vcard.setAnniversary(anniversary);
059 *
060 * //plain text value
061 * anniversary = new AnniversaryType();
062 * anniversary.setText("more than 20 years ago");
063 * vcard.setAnniversary(anniversary);
064 * </pre>
065 *
066 * <p>
067 * <b>Getting the anniversary</b>
068 * </p>
069 *
070 * <pre>
071 * VCard vcard = ...
072 * AnniversaryType anniversary = vcard.getAnniversary();
073 * if (anniversary != null){
074 * if (anniversary.getDate() != null){
075 * System.out.println(anniversary.getDate());
076 * } else if (anniversary.getReducedAccuracyDate() != null){
077 * System.out.println(anniversary.getReducedAccuracyDate());
078 * } else if (anniversary.getText() != null){
079 * System.out.println(anniversary.getText());
080 * }
081 * }
082 * </pre>
083 *
084 * <p>
085 * vCard property name: ANNIVERSARY
086 * </p>
087 * <p>
088 * vCard versions: 4.0
089 * </p>
090 * @author Michael Angstadt
091 */
092 public class AnniversaryType extends DateOrTimeType {
093 public static final String NAME = "ANNIVERSARY";
094
095 public AnniversaryType() {
096 super(NAME);
097 }
098
099 /**
100 * @param date the anniversary date
101 */
102 public AnniversaryType(Date date) {
103 super(NAME, date);
104 }
105
106 @Override
107 public VCardVersion[] getSupportedVersions() {
108 return new VCardVersion[] { VCardVersion.V4_0 };
109 }
110 }