ezvcard.property
Class Anniversary

java.lang.Object
  extended by ezvcard.property.VCardProperty
      extended by ezvcard.property.DateOrTimeProperty
          extended by ezvcard.property.Anniversary
All Implemented Interfaces:
HasAltId, Comparable<VCardProperty>

public class Anniversary
extends DateOrTimeProperty

Defines the person's anniversary.

Setting the anniversary

 VCard vcard = new VCard();
 
 //complete date
 Calendar c = Calendar.getInstance();
 c.set(Calendar.YEAR, 1986);
 c.set(Calendar.MONTH, Calendar.MARCH);
 c.set(Calendar.DAY_OF_MONTH, 21);
 Anniversary anniversary = new Anniversary();
 anniversary.setDate(c.getTime(), false);
 vcard.setAnniversary(anniversary);
 
 //reduced accuracy date (see RFC 6350 p.12-14 for examples)
 anniversary = new Anniversary();
 anniversary.setPartialDate(PartialDate.date(null, 3, 21)); //March 21
 vcard.setAnniversary(anniversary);
 
 //plain text value
 anniversary = new Anniversary();
 anniversary.setText("more than 20 years ago");
 vcard.setAnniversary(anniversary);
 

Getting the anniversary

 VCard vcard = ...
 Anniversary anniversary = vcard.getAnniversary();
 if (anniversary != null){
   if (anniversary.getDate() != null){
     System.out.println(anniversary.getDate());
   } else if (anniversary.getPartialDate() != null){
     System.out.println("Year: " + anniversary.getPartialDate().getYear());
     System.out.println("Month: " + anniversary.getPartialDate().getMonth());
     //...
   } else if (anniversary.getText() != null){
     System.out.println(anniversary.getText());
   }
 }
 

Property name: ANNIVERSARY

Supported versions: 4.0

Author:
Michael Angstadt

Field Summary
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
Anniversary(Date date)
          Creates an anniversary property.
Anniversary(Date date, boolean hasTime)
          Creates an anniversary property.
Anniversary(PartialDate partialDate)
          Creates an anniversary property.
Anniversary(String text)
          Creates an anniversary property.
 
Method Summary
 Set<VCardVersion> _supportedVersions()
           Gets the vCard versions that support this property.
 
Methods inherited from class ezvcard.property.DateOrTimeProperty
_validate, getAltId, getCalscale, getDate, getPartialDate, getText, hasTime, setAltId, setCalscale, setDate, setPartialDate, setText
 
Methods inherited from class ezvcard.property.VCardProperty
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, removeParameter, setGroup, setParameter, setParameters, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Anniversary

public Anniversary(Date date)
Creates an anniversary property.

Parameters:
date - the anniversary date

Anniversary

public Anniversary(Date date,
                   boolean hasTime)
Creates an anniversary property.

Parameters:
date - the anniversary date
hasTime - true to include the date's time component, false if it's strictly a date

Anniversary

public Anniversary(PartialDate partialDate)
Creates an anniversary property.

Parameters:
partialDate - the partial anniversary date (vCard 4.0 only)

Anniversary

public Anniversary(String text)
Creates an anniversary property.

Parameters:
text - the text value (vCard 4.0 only)
Method Detail

_supportedVersions

public Set<VCardVersion> _supportedVersions()
Description copied from class: VCardProperty

Gets the vCard versions that support this property.

This method should be overridden by child classes if the property does not support all vCard versions. The default implementation of this method returns all vCard versions.

Overrides:
_supportedVersions in class VCardProperty
Returns:
the vCard versions that support this property.


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.