public class Birthday extends DateOrTimeProperty
Defines the person's birthday.
Code sample (creating)
VCard vcard = new VCard(); //date LocalDate date = LocalDate.of(1912, 6, 23); Birthday bday = new Birthday(date); vcard.setBirthday(bday); //partial date (e.g. just the month and date, vCard 4.0 only) bday = new Birthday(PartialDate.date(null, 6, 23)); //June 23 vcard.setBirthday(bday); //plain text value (vCard 4.0 only) bday = new Birthday("Don't even go there, dude..."); vcard.setBirthday(bday);
Code sample (retrieving)
VCard vcard = ... Birthday bday = vcard.getBirthday(); Temporal date = bday.getDate(); if (date != null) { //property value is a date } PartialDate partialDate = bday.getPartialDate(); if (partialDate != null) { //property value is a partial date int year = partialDate.getYear(); int month = partialDate.getMonth(); } String text = bday.getText(); if (text != null) { //property value is plain text }
Property name: BDAY
Supported versions: 2.1, 3.0, 4.0
group, parameters
Constructor and Description |
---|
Birthday(Birthday original)
Copy constructor.
|
Birthday(PartialDate partialDate)
Creates a birthday property.
|
Birthday(String text)
Creates a birthday property.
|
Birthday(Temporal date)
Creates a birthday property.
|
Modifier and Type | Method and Description |
---|---|
Birthday |
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 Birthday(Temporal date)
date
- the birthday (can be a date, date/time, or date/time with
offset value)public Birthday(PartialDate partialDate)
partialDate
- the birthday (vCard 4.0 only)public Birthday(String text)
text
- the text value (vCard 4.0 only)public Birthday 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.