public class Timezone extends VCardProperty implements HasAltId
Defines the timezone that the person lives/works in.
Code sample
VCard vcard = new VCard(); Timezone tz = new Timezone(ZoneOffset.ofHours(-5), "America/New_York"); vcard.addTimezone(tz); //using a Java "ZoneId" object ZoneId zoneId = ZoneId.of("America/New_York"); tz = new Timezone(zoneId); vcard.addTimezone(tz);
Property name: TZ
Supported versions: 2.1, 3.0, 4.0
group, parameters
Constructor and Description |
---|
Timezone(String text)
Creates a timezone property.
|
Timezone(Timezone original)
Copy constructor.
|
Timezone(ZoneId timezone)
Creates a timezone property.
|
Timezone(ZoneOffset offset)
Creates a timezone property.
|
Timezone(ZoneOffset offset,
String text)
Creates a timezone property.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_validate(List<ValidationWarning> warnings,
VCardVersion version,
VCard vcard)
Checks the property for data consistency problems or deviations from the
spec.
|
Timezone |
copy()
Creates a copy of this property object.
|
boolean |
equals(Object obj) |
String |
getAltId()
Gets the property's ALTID parameter.
|
String |
getMediaType()
Gets the MEDIATYPE parameter.
|
ZoneOffset |
getOffset()
Gets the UTC offset.
|
List<Pid> |
getPids()
Gets the list that stores this property's PID (property ID) parameter
values.
|
Integer |
getPref()
Gets this property's preference value.
|
String |
getText()
Gets the text portion of the timezone.
|
String |
getType()
Gets the TYPE parameter.
|
int |
hashCode() |
void |
setAltId(String altId)
Sets the property's ALTID parameter.
|
void |
setMediaType(String mediaType)
Sets the MEDIATYPE parameter.
|
void |
setOffset(ZoneOffset offset)
Sets the UTC offset.
|
void |
setPref(Integer pref)
Sets this property's preference value.
|
void |
setText(String text)
Sets the text portion of the timezone.
|
void |
setType(String type)
Sets the TYPE parameter.
|
protected Map<String,Object> |
toStringValues()
Gets string representations of the class's fields for the
VCardProperty.toString() method. |
ZoneId |
toTimeZone()
Creates a
ZoneId representation of this class. |
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, isSupportedBy, removeParameter, setGroup, setParameter, setParameters, toString, validate
public Timezone(String text)
text
- a free-form string representing the timezone, preferably a
timezone ID from the Olson
Database (e.g. "America/New_York")public Timezone(ZoneOffset offset)
offset
- the UTC offsetpublic Timezone(ZoneOffset offset, String text)
offset
- the UTC offsettext
- a free-form string representing the timezone, preferably a
timezone ID from the Olson
Database (e.g. "America/New_York")public Timezone(ZoneId timezone)
timezone
- the timezonepublic ZoneOffset getOffset()
public void setOffset(ZoneOffset offset)
offset
- the UTC offsetpublic String getText()
public void setText(String text)
text
- a free-form string representing the timezone, preferably a
timezone ID from the Olson
Database (e.g. "America/New_York")public ZoneId toTimeZone()
ZoneId
representation of this class.ZoneId
object or null if this object contains no
offset datapublic String getType()
Supported versions: 4.0
public void setType(String type)
Supported versions: 4.0
type
- the TYPE value (this should be either "work" or "home") or
null to removepublic String getMediaType()
Supported versions: 4.0
public void setMediaType(String mediaType)
Supported versions: 4.0
mediaType
- the media type or null to removepublic List<Pid> getPids()
VCardProperty
Gets the list that stores this property's PID (property ID) parameter values.
PIDs can exist on any property where multiple instances are allowed (such
as Email
or Address
, but not StructuredName
because only 1 instance of this property is allowed per vCard).
When used in conjunction with the ClientPidMap
property, it
allows an individual property instance to be uniquely identifiable. This
feature is made use of when two different versions of the same vCard have
to be merged together (called "synchronizing").
Supported versions: 4.0
public Integer getPref()
VCardProperty
Gets this property's preference value. The lower this number is, the more "preferred" the property instance is compared with other properties of the same type. If a property doesn't have a preference value, then it is considered the least preferred.
In the vCard below, the Address
on the second row is the most
preferred because it has the lowest PREF value.
ADR;TYPE=work;PREF=2:;;1600 Amphitheatre Parkway;Mountain View;CA;94043 ADR;TYPE=work;PREF=1:;;One Microsoft Way;Redmond;WA;98052 ADR;TYPE=home:;;123 Maple St;Hometown;KS;12345
Supported versions: 4.0
public void setPref(Integer pref)
VCardProperty
Sets this property's preference value. The lower this number is, the more "preferred" the property instance is compared with other properties of the same type. If a property doesn't have a preference value, then it is considered the least preferred.
In the vCard below, the Address
on the second row is the most
preferred because it has the lowest PREF value.
ADR;TYPE=work;PREF=2:;;1600 Amphitheatre Parkway;Mountain View;CA;94043 ADR;TYPE=work;PREF=1:;;One Microsoft Way;Redmond;WA;98052 ADR;TYPE=home:;;123 Maple St;Hometown;KS;12345
Supported versions: 4.0
pref
- the preference value or null to removepublic String getAltId()
HasAltId
Supported versions: 4.0
getAltId
in interface HasAltId
VCardParameters.getAltId()
public void setAltId(String altId)
HasAltId
Supported versions: 4.0
setAltId
in interface HasAltId
altId
- the ALTID or null to removeVCardParameters.setAltId(java.lang.String)
protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard)
VCardProperty
_validate
in class VCardProperty
warnings
- the list to add the warnings toversion
- the version to check the property againstvcard
- the vCard this property belongs toprotected Map<String,Object> toStringValues()
VCardProperty
Gets string representations of the class's fields for the
VCardProperty.toString()
method.
Meant to be overridden by child classes. The default implementation returns an empty map.
toStringValues
in class VCardProperty
public Timezone 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
public int hashCode()
hashCode
in class VCardProperty
public boolean equals(Object obj)
equals
in class VCardProperty
Copyright © 2012–2023 Michael Angstadt. All rights reserved.