ezvcard.property
Class DateOrTimeProperty

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

public class DateOrTimeProperty
extends VCardProperty
implements HasAltId

Represents a property whose value contains a date and/or a time (for example, Birthday).

Author:
Michael Angstadt

Field Summary
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
DateOrTimeProperty(Date date)
          Creates a date-and-or-time property.
DateOrTimeProperty(Date date, boolean hasTime)
          Creates a date-and-or-time property.
DateOrTimeProperty(PartialDate partialDate)
          Creates a date-and-or-time property.
DateOrTimeProperty(String text)
          Creates a date-and-or-time property.
 
Method Summary
protected  void _validate(List<Warning> warnings, VCardVersion version, VCard vcard)
          Checks the property for data consistency problems or deviations from the spec.
 String getAltId()
          Gets the property's ALTID parameter.
 Calscale getCalscale()
           Gets the type of calendar that is used for a date or date-time property value.
 Date getDate()
          Gets the date value.
 PartialDate getPartialDate()
          Gets the reduced accuracy or truncated date.
 String getText()
          Gets the text value of this type.
 boolean hasTime()
          Determines whether the "date" or "partialDate" fields have a time component.
 void setAltId(String altId)
          Sets the property's ALTID parameter.
 void setCalscale(Calscale calscale)
           Sets the type of calendar that is used for a date or date-time property value.
 void setDate(Date date, boolean hasTime)
          Sets the value of this property to a complete date.
 void setPartialDate(PartialDate partialDate)
           Sets the value of this property to a reduced accuracy or truncated date.
 void setText(String text)
          Sets the value of this property to a text string.
 
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

DateOrTimeProperty

public DateOrTimeProperty(Date date)
Creates a date-and-or-time property.

Parameters:
date - the date value

DateOrTimeProperty

public DateOrTimeProperty(Date date,
                          boolean hasTime)
Creates a date-and-or-time property.

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

DateOrTimeProperty

public DateOrTimeProperty(PartialDate partialDate)
Creates a date-and-or-time property.

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

DateOrTimeProperty

public DateOrTimeProperty(String text)
Creates a date-and-or-time property.

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

getDate

public Date getDate()
Gets the date value.

Returns:
the date value or null if not set

setDate

public void setDate(Date date,
                    boolean hasTime)
Sets the value of this property to a complete date.

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

getPartialDate

public PartialDate getPartialDate()
Gets the reduced accuracy or truncated date. This is only supported by vCard 4.0.

Returns:
the reduced accuracy or truncated date or null if not set
See Also:
"RFC 6350 p.12-14 for examples"

setPartialDate

public void setPartialDate(PartialDate partialDate)

Sets the value of this property to a reduced accuracy or truncated date. This is only supported by vCard 4.0.

 Birthday bday = new Birthday();
 bday.setPartialDate(PartialDate.date(null, 4, 20)); //April 20
 

Parameters:
partialDate - the reduced accuracy or truncated date
See Also:
"RFC 6350 p.12-14 for examples"

getText

public String getText()
Gets the text value of this type. This is only supported by vCard 4.0.

Returns:
the text value or null if not set

setText

public void setText(String text)
Sets the value of this property to a text string. This is only supported by vCard 4.0.

Parameters:
text - the text value

hasTime

public boolean hasTime()
Determines whether the "date" or "partialDate" fields have a time component.

Returns:
true if the date has a time component, false if it's strictly a date, and false if a text value is defined

getCalscale

public Calscale getCalscale()

Gets the type of calendar that is used for a date or date-time property value.

Supported versions: 4.0

Returns:
the type of calendar or null if not found
See Also:
VCardParameters.getCalscale()

setCalscale

public void setCalscale(Calscale calscale)

Sets the type of calendar that is used for a date or date-time property value.

Supported versions: 4.0

Parameters:
calscale - the type of calendar or null to remove
See Also:
VCardParameters.setCalscale(ezvcard.parameter.Calscale)

getAltId

public String getAltId()
Description copied from interface: HasAltId
Gets the property's ALTID parameter.

Supported versions: 4.0

Specified by:
getAltId in interface HasAltId
Returns:
the ALTID or null if it doesn't exist
See Also:
VCardParameters.getAltId()

setAltId

public void setAltId(String altId)
Description copied from interface: HasAltId
Sets the property's ALTID parameter.

Supported versions: 4.0

Specified by:
setAltId in interface HasAltId
Parameters:
altId - the ALTID or null to remove
See Also:
VCardParameters.setAltId(java.lang.String)

_validate

protected void _validate(List<Warning> warnings,
                         VCardVersion version,
                         VCard vcard)
Description copied from class: VCardProperty
Checks the property for data consistency problems or deviations from the spec. Meant to be overridden by child classes that wish to provide validation logic.

Overrides:
_validate in class VCardProperty
Parameters:
warnings - the list to add the warnings to
version - the version to check the property against
vcard - the vCard this property belongs to


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