use of ezvcard.property.Timezone in project ez-vcard by mangstadt.
the class JCardWriterTest method createExample.
public static VCard createExample() {
VCard vcard = new VCard();
vcard.setFormattedName("SimonPerreault");
StructuredName n = new StructuredName();
n.setFamily("Perreault");
n.setGiven("Simon");
n.getSuffixes().add("ing.jr");
n.getSuffixes().add("M.Sc.");
vcard.setStructuredName(n);
Birthday bday = new Birthday(PartialDate.builder().month(2).date(3).build());
vcard.setBirthday(bday);
Anniversary anniversary = new Anniversary(PartialDate.builder().year(2009).month(8).date(8).hour(14).minute(30).second(0).offset(new UtcOffset(false, -5, 0)).build());
vcard.setAnniversary(anniversary);
vcard.setGender(Gender.male());
vcard.addLanguage("fr").setPref(1);
vcard.addLanguage("en").setPref(2);
vcard.setOrganization("Viagenie").setType("work");
Address adr = new Address();
adr.setExtendedAddress("SuiteD2-630");
adr.setStreetAddress("2875Laurier");
adr.setLocality("Quebec");
adr.setRegion("QC");
adr.setPostalCode("G1V2M2");
adr.setCountry("Canada");
adr.getTypes().add(AddressType.WORK);
vcard.addAddress(adr);
TelUri telUri = new TelUri.Builder("+1-418-656-9254").extension("102").build();
Telephone tel = new Telephone(telUri);
tel.getTypes().add(TelephoneType.WORK);
tel.getTypes().add(TelephoneType.VOICE);
tel.setPref(1);
vcard.addTelephoneNumber(tel);
tel = new Telephone(new TelUri.Builder("+1-418-262-6501").build());
tel.getTypes().add(TelephoneType.WORK);
tel.getTypes().add(TelephoneType.CELL);
tel.getTypes().add(TelephoneType.VOICE);
tel.getTypes().add(TelephoneType.VIDEO);
tel.getTypes().add(TelephoneType.TEXT);
vcard.addTelephoneNumber(tel);
vcard.addEmail("simon.perreault@viagenie.ca", EmailType.WORK);
Geo geo = new Geo(46.772673, -71.282945);
geo.setType("work");
vcard.setGeo(geo);
Key key = new Key("http://www.viagenie.ca/simon.perreault/simon.asc", null);
key.setType("work");
vcard.addKey(key);
vcard.setTimezone(new Timezone(new UtcOffset(false, -5, 0)));
vcard.addUrl("http://nomis80.org").setType("home");
return vcard;
}
use of ezvcard.property.Timezone in project ez-vcard by mangstadt.
the class TimezoneScribe method _parseXml.
@Override
protected Timezone _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) {
String text = element.first(VCardDataType.TEXT);
if (text != null) {
return new Timezone(text);
}
String utcOffset = element.first(VCardDataType.UTC_OFFSET);
if (utcOffset != null) {
try {
return new Timezone(UtcOffset.parse(utcOffset));
} catch (IllegalArgumentException e) {
throw new CannotParseException(19);
}
}
throw missingXmlElements(VCardDataType.TEXT, VCardDataType.UTC_OFFSET);
}
Aggregations