001    package ezvcard.types;
002    
003    import java.util.Date;
004    
005    /*
006     Copyright (c) 2012, Michael Angstadt
007     All rights reserved.
008    
009     Redistribution and use in source and binary forms, with or without
010     modification, are permitted provided that the following conditions are met: 
011    
012     1. Redistributions of source code must retain the above copyright notice, this
013     list of conditions and the following disclaimer. 
014     2. Redistributions in binary form must reproduce the above copyright notice,
015     this list of conditions and the following disclaimer in the documentation
016     and/or other materials provided with the distribution. 
017    
018     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
019     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
020     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
021     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022     ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
023     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
025     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028    
029     The views and conclusions contained in the software and documentation are those
030     of the authors and should not be interpreted as representing official policies, 
031     either expressed or implied, of the FreeBSD Project.
032     */
033    
034    /**
035     * Defines the person's birthday.
036     * 
037     * <p>
038     * <b>Setting the birthday</b>
039     * </p>
040     * 
041     * <pre>
042     * VCard vcard = new VCard();
043     * 
044     * //complete date
045     * Calendar c = Calendar.getInstance();
046     * c.set(Calendar.YEAR, 1986);
047     * c.set(Calendar.MONTH, Calendar.MARCH);
048     * c.set(Calendar.DAY_OF_MONTH, 21);
049     * BirthdayType bday = new BirthdayType();
050     * bday.setDate(c.getTime(), false);
051     * vcard.setBirthday(bday);
052     * 
053     * //reduced accuracy date (vCard 4.0 only, see RFC 6350 p.12-14 for examples)
054     * bday = new BirthdayType();
055     * bday.setReducedAccuracyDate(&quot;--0321&quot;); //March 21
056     * vcard.setBirthday(bday);
057     * 
058     * //plain text value (vCard 4.0 only)
059     * bday = new BirthdayType();
060     * bday.setText(&quot;a long time ago&quot;);
061     * vcard.setBirthday(bday);
062     * </pre>
063     * 
064     * <p>
065     * <b>Getting the birthday</b>
066     * </p>
067     * 
068     * <pre>
069     * VCard vcard = ...
070     * BirthdayType bday = vcard.getBirthday();
071     * if (bday != null){
072     *   if (bday.getDate() != null){
073     *     System.out.println(bday.getDate());
074     *   } else if (bday.getReducedAccuracyDate() != null){
075     *     System.out.println(bday.getReducedAccuracyDate());
076     *   } else if (bday.getText() != null){
077     *     System.out.println(bday.getText());
078     *   }
079     * }
080     * </pre>
081     * 
082     * <p>
083     * vCard property name: BDAY
084     * </p>
085     * <p>
086     * vCard versions: 2.1, 3.0, 4.0
087     * </p>
088     * @author Michael Angstadt
089     */
090    public class BirthdayType extends DateOrTimeType {
091            public static final String NAME = "BDAY";
092    
093            public BirthdayType() {
094                    super(NAME);
095            }
096    
097            /**
098             * @param date the birthday
099             */
100            public BirthdayType(Date date) {
101                    super(NAME, date);
102            }
103    }