ezvcard.property
Class Birthday

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

public class Birthday
extends DateOrTimeProperty

Defines the person's birthday.

Setting the birthday

 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);
 Birthday bday = new Birthday();
 bday.setDate(c.getTime(), false);
 vcard.setBirthday(bday);
 
 //reduced accuracy date (vCard 4.0 only, see RFC 6350 p.12-14 for examples)
 bday = new Birthday();
 bday.setPartialDate(PartialDate.date(null, 3, 21)); //March 21
 vcard.setBirthday(bday);
 
 //plain text value (vCard 4.0 only)
 bday = new Birthday();
 bday.setText("a long time ago");
 vcard.setBirthday(bday);
 

Getting the birthday

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

Property name: BDAY

Supported versions: 2.1, 3.0, 4.0

Author:
Michael Angstadt

Field Summary
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
Birthday(Date date)
          Creates a birthday property.
Birthday(Date date, boolean hasTime)
          Creates a birthday property.
Birthday(PartialDate partialDate)
          Creates a birthday property.
Birthday(String text)
          Creates a birthday property.
 
Method Summary
 
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
_supportedVersions, 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

Birthday

public Birthday(Date date)
Creates a birthday property.

Parameters:
date - the birthday

Birthday

public Birthday(Date date,
                boolean hasTime)
Creates a birthday property.

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

Birthday

public Birthday(PartialDate partialDate)
Creates a birthday property.

Parameters:
partialDate - the birthday (vCard 4.0 only)

Birthday

public Birthday(String text)
Creates a birthday property.

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


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