public class Anniversary extends DateOrTimeProperty
Defines the person's anniversary (marital or work-related).
Code sample (creating)
VCard vcard = new VCard(); //date Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.YEAR, 1970); c.set(Calendar.MONTH, Calendar.MARCH); c.set(Calendar.DAY_OF_MONTH, 21); Anniversary anniversary = new Anniversary(c.getTime()); vcard.setAnniversary(anniversary); //partial date (e.g. just the month and date) PartialDate date = PartialDate.date(null, 3, 21); anniversary = new Anniversary(date); //March 21 vcard.setAnniversary(anniversary); //plain text value anniversary = new Anniversary("Over 20 years ago!"); vcard.setAnniversary(anniversary);
Code sample (retrieving)
VCard vcard = ... Anniversary anniversary = vcard.getAnniversary(); Date date = anniversary.getDate(); if (date != null){ //property value is a date } PartialDate partialDate = anniversary.getPartialDate(); if (partialDate != null){ //property value is a partial date int year = partialDate.getYear(); int month = partialDate.getMonth(); } String text = anniversary.getText(); if (text != null){ //property value is plain text }
Property name: ANNIVERSARY
Supported versions: 4.0
group, parameters
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
Set<VCardVersion> |
_supportedVersions()
Gets the vCard versions that support this property.
|
_validate, getAltId, getCalscale, getDate, getPartialDate, getText, hasTime, setAltId, setCalscale, setDate, setPartialDate, setText
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, removeParameter, setGroup, setParameter, setParameters, validate
public Anniversary(Date date)
date
- the anniversary datepublic Anniversary(Date date, boolean hasTime)
date
- the anniversary datehasTime
- true to include the date's time component, false if it's
strictly a datepublic Anniversary(PartialDate partialDate)
partialDate
- the partial anniversary date (vCard 4.0 only)public Anniversary(String text)
text
- the text value (vCard 4.0 only)public Set<VCardVersion> _supportedVersions()
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.
_supportedVersions
in class VCardProperty
This software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.