@SupportedVersions(value=V4_0) public class Anniversary extends DateOrTimeProperty
Defines the person's anniversary (marital or work-related).
Code sample (creating)
VCard vcard = new VCard(); //date LocalDate date = LocalDate.of(1970, 3, 21); Anniversary anniversary = new Anniversary(date); 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(); Temporal 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(Anniversary original)
Copy constructor.
|
Anniversary(PartialDate partialDate)
Creates an anniversary property.
|
Anniversary(String text)
Creates an anniversary property.
|
Anniversary(Temporal date)
Creates an anniversary property.
|
Modifier and Type | Method and Description |
---|---|
Anniversary |
copy()
Creates a copy of this property object.
|
_validate, equals, getAltId, getCalscale, getDate, getLanguage, getPartialDate, getText, hashCode, setAltId, setCalscale, setDate, setLanguage, setPartialDate, setText, toStringValues
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, isSupportedBy, removeParameter, setGroup, setParameter, setParameters, toString, validate
public Anniversary(Temporal date)
date
- the anniversary 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 Anniversary(Anniversary original)
original
- the property to make a copy ofpublic Anniversary copy()
VCardProperty
Creates a copy of this property object.
The default implementation of this method uses reflection to look for a copy constructor. Child classes SHOULD override this method to avoid the performance overhead involved in using reflection.
The child class's copy constructor, if present, MUST invoke the
VCardProperty.VCardProperty(VCardProperty)
super constructor to ensure that
the group name and parameters are also copied.
This method MUST be overridden by the child class if the child class does
not have a copy constructor. Otherwise, an
UnsupportedOperationException
will be thrown when an attempt is
made to copy the property (such as in the VCard
class's copy constructor
).
copy
in class VCardProperty
Copyright © 2012–2023 Michael Angstadt. All rights reserved.