Example usage for org.joda.time DateTimeZone forID

List of usage examples for org.joda.time DateTimeZone forID

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone forID.

Prototype

@FromString
public static DateTimeZone forID(String id) 

Source Link

Document

Gets a time zone instance for the specified time zone id.

Usage

From source file:com.sonicle.webtop.calendar.TplHelper.java

License:Open Source License

private static String buildEventTitle(Locale locale, String dateFormat, String timeFormat,
        EventFootprint event) {/*from   w w w  .  j av  a  2  s  . com*/
    DateTimeZone etz = DateTimeZone.forID(event.getTimezone());
    DateTimeFormatter fmt = DateTimeUtils.createFormatter(dateFormat + " " + timeFormat, etz);
    StringBuilder sb = new StringBuilder();

    sb.append(StringUtils.abbreviate(event.getTitle(), 30));
    sb.append(" @");

    if (!StringUtils.isEmpty(event.getRecurrenceRule())) {
        RRuleStringify.Strings strings = WT.getRRuleStringifyStrings(locale);
        RRuleStringify rrs = new RRuleStringify(strings, etz);
        sb.append(" (");
        sb.append(rrs.toHumanReadableFrequencyQuietly(event.getRecurrenceRule()));
        sb.append(")");
    }

    //TODO: solo l'orario se date coincidono!!!
    sb.append(" ");
    sb.append(fmt.print(event.getStartDate()));
    sb.append(" - ");
    sb.append(fmt.print(event.getEndDate()));

    return sb.toString();
}

From source file:com.sonicle.webtop.calendar.TplHelper.java

License:Open Source License

public static String buildEventModificationTitle(Locale locale, EventFootprint event, String crud) {
    DateTimeZone etz = DateTimeZone.forID(event.getTimezone());
    StringBuilder sb = new StringBuilder();

    sb.append(StringUtils.abbreviate(event.getTitle(), 30));
    sb.append(" @");

    if (!StringUtils.isEmpty(event.getRecurrenceRule())) {
        RRuleStringify.Strings strings = WT.getRRuleStringifyStrings(locale);
        RRuleStringify rrs = new RRuleStringify(strings, etz);
        sb.append(" (");
        sb.append(rrs.toHumanReadableFrequencyQuietly(event.getRecurrenceRule()));
        sb.append(")");
    }// w  w  w .j  a v a 2s  . c o  m

    String SUJECT_KEY = MessageFormatter.format(CalendarLocale.EMAIL_EVENTMODIFICATION_SUBJECT_X, crud)
            .getMessage();
    return MessageFormat.format(WT.lookupResource(SERVICE_ID, locale, SUJECT_KEY), sb.toString());
}

From source file:com.sonicle.webtop.calendar.TplHelper.java

License:Open Source License

public static String buildEventModificationBody(Locale locale, String dateFormat, String timeFormat,
        EventFootprint event) throws IOException, TemplateException, AddressException {
    DateTimeZone etz = DateTimeZone.forID(event.getTimezone());

    MapItem i18n = new MapItem();
    i18n.put("whenStart",
            WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_START));
    i18n.put("whenEnd", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_END));
    i18n.put("where", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE));
    i18n.put("whereMap", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE_MAP));

    DateTimeFormatter fmt = DateTimeUtils.createFormatter(dateFormat + " " + timeFormat, etz);
    MapItem evt = new MapItem();
    evt.put("timezone", event.getTimezone());
    evt.put("startDate", fmt.print(event.getStartDate()));
    evt.put("endDate", fmt.print(event.getEndDate()));
    evt.put("occurs", null);
    if (!StringUtils.isEmpty(event.getRecurrenceRule())) {
        RRuleStringify.Strings strings = WT.getRRuleStringifyStrings(locale);
        RRuleStringify rrs = new RRuleStringify(strings, etz);
        evt.put("occurs", rrs.toHumanReadableTextQuietly(event.getRecurrenceRule()));
    }//from   www .ja va 2s .c  o m
    evt.put("location", StringUtils.defaultIfBlank(event.getLocation(), null));
    evt.put("locationUrl", TplHelper.buildGoogleMapsUrl(event.getLocation()));

    MapItem vars = new MapItem();
    vars.put("i18n", i18n);
    vars.put("event", evt);

    return WT.buildTemplate(SERVICE_ID, "tpl/email/eventModification-body.html", vars);
}

From source file:com.sonicle.webtop.calendar.TplHelper.java

License:Open Source License

public static String buildTplEventInvitationBody(Locale locale, String dateFormat, String timeFormat,
        Event event, String crud, String recipientEmail, String servicePublicUrl)
        throws IOException, TemplateException, AddressException {
    DateTimeZone etz = DateTimeZone.forID(event.getTimezone());

    MapItem i18n = new MapItem();
    i18n.put("whenStart",
            WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_START));
    i18n.put("whenEnd", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_END));
    i18n.put("where", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE));
    i18n.put("whereMap", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE_MAP));
    i18n.put("organizer", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_ORGANIZER));
    i18n.put("who", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHO));
    i18n.put("going", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_GOING));
    i18n.put("goingToAll",
            WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_GOINGTOALL));
    i18n.put("goingYes", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_GOING_YES));
    i18n.put("goingMaybe",
            WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_GOING_MAYBE));
    i18n.put("goingNo", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_GOING_NO));
    i18n.put("view", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_VIEW));

    DateTimeFormatter fmt = DateTimeUtils.createFormatter(dateFormat + " " + timeFormat, etz);
    MapItem evt = new MapItem();
    evt.put("title", StringUtils.defaultIfBlank(event.getTitle(), ""));
    evt.put("description", StringUtils.defaultIfBlank(event.getDescription(), null));
    evt.put("timezone", event.getTimezone());
    evt.put("startDate", fmt.print(event.getStartDate()));
    evt.put("endDate", fmt.print(event.getEndDate()));
    evt.put("occurs", null);
    if (!StringUtils.isEmpty(event.getRecurrenceRule())) {
        RRuleStringify.Strings strings = WT.getRRuleStringifyStrings(locale);
        RRuleStringify rrs = new RRuleStringify(strings, etz);
        evt.put("occurs", rrs.toHumanReadableTextQuietly(event.getRecurrenceRule()));
    }// w  ww . j av  a  2 s .co m
    evt.put("location", StringUtils.defaultIfBlank(event.getLocation(), null));
    evt.put("locationUrl", TplHelper.buildGoogleMapsUrl(event.getLocation()));
    evt.put("organizer", StringUtils.defaultIfBlank(event.getOrganizerCN(), event.getOrganizerAddress()));

    String recipientAttendeeId = null;
    MapItemList evtAtts = new MapItemList();
    for (EventAttendee attendee : event.getAttendees()) {
        MapItem item = new MapItem();
        String cn = attendee.getCN();
        String address = attendee.getAddress();
        if (StringUtils.equals(address, recipientEmail))
            recipientAttendeeId = attendee.getAttendeeId();
        item.put("cn", StringUtils.isBlank(cn) ? null : cn);
        item.put("address", StringUtils.isBlank(address) ? null : address);
        evtAtts.add(item);
    }

    String viewUrl = CalendarManager.buildEventPublicUrl(servicePublicUrl, event.getPublicUid());

    MapItem vars = new MapItem();
    vars.put("i18n", i18n);
    vars.put("event", evt);
    vars.put("eventAttendees", evtAtts);
    if (!StringUtils.equals(crud, "delete")) {
        vars.put("replyYesUrl",
                (recipientAttendeeId == null) ? null
                        : CalendarManager.buildEventReplyPublicUrl(servicePublicUrl, event.getPublicUid(),
                                recipientAttendeeId, "yes"));
        vars.put("replyMaybeUrl",
                (recipientAttendeeId == null) ? null
                        : CalendarManager.buildEventReplyPublicUrl(servicePublicUrl, event.getPublicUid(),
                                recipientAttendeeId, "maybe"));
        vars.put("replyNoUrl",
                (recipientAttendeeId == null) ? null
                        : CalendarManager.buildEventReplyPublicUrl(servicePublicUrl, event.getPublicUid(),
                                recipientAttendeeId, "no"));
        vars.put("viewUrl", viewUrl);
    }

    return WT.buildTemplate(SERVICE_ID, "tpl/email/eventInvitation-body.html", vars);
}

From source file:com.sonicle.webtop.calendar.TplHelper.java

License:Open Source License

public static String buildTplResponseUpdateBody(Locale locale, String dateFormat, String timeFormat,
        Event event, String servicePublicUrl) throws IOException, TemplateException, AddressException {
    DateTimeZone etz = DateTimeZone.forID(event.getTimezone());

    MapItem i18n = new MapItem();
    i18n.put("whenStart",
            WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_START));
    i18n.put("whenEnd", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_END));
    i18n.put("where", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE));
    i18n.put("whereMap", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE_MAP));
    i18n.put("view", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_VIEW));

    DateTimeFormatter fmt = DateTimeUtils.createFormatter(dateFormat + " " + timeFormat, etz);
    MapItem evt = new MapItem();
    evt.put("title", StringUtils.defaultIfBlank(event.getTitle(), ""));
    evt.put("timezone", event.getTimezone());
    evt.put("startDate", fmt.print(event.getStartDate()));
    evt.put("endDate", fmt.print(event.getEndDate()));
    evt.put("occurs", null);
    if (!StringUtils.isEmpty(event.getRecurrenceRule())) {
        RRuleStringify.Strings strings = WT.getRRuleStringifyStrings(locale);
        RRuleStringify rrs = new RRuleStringify(strings, etz);
        evt.put("occurs", rrs.toHumanReadableTextQuietly(event.getRecurrenceRule()));
    }//w w  w.  j  a  v  a  2 s. c om
    evt.put("location", StringUtils.defaultIfBlank(event.getLocation(), null));
    evt.put("locationUrl", TplHelper.buildGoogleMapsUrl(event.getLocation()));

    String viewUrl = CalendarManager.buildEventPublicUrl(servicePublicUrl, event.getPublicUid());

    MapItem vars = new MapItem();
    vars.put("i18n", i18n);
    vars.put("event", evt);
    vars.put("viewUrl", viewUrl);

    return WT.buildTemplate(SERVICE_ID, "tpl/email/responseUpdate-body.html", vars);
}

From source file:com.sonicle.webtop.calendar.TplHelper.java

License:Open Source License

public static String buildTplEventReminderBody(Locale locale, String dateFormat, String timeFormat, Event event)
        throws IOException, TemplateException, AddressException {
    DateTimeZone etz = DateTimeZone.forID(event.getTimezone());

    MapItem i18n = new MapItem();
    i18n.put("whenStart",
            WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_START));
    i18n.put("whenEnd", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHEN_END));
    i18n.put("where", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE));
    i18n.put("whereMap", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHERE_MAP));
    i18n.put("organizer", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_ORGANIZER));
    i18n.put("who", WT.lookupResource(SERVICE_ID, locale, CalendarLocale.TPL_EMAIL_INVITATION_WHO));

    DateTimeFormatter fmt = DateTimeUtils.createFormatter(dateFormat + " " + timeFormat, etz);
    MapItem evt = new MapItem();
    evt.put("title", StringUtils.defaultIfBlank(event.getTitle(), ""));
    evt.put("description", StringUtils.defaultIfBlank(event.getDescription(), null));
    evt.put("timezone", event.getTimezone());
    evt.put("startDate", fmt.print(event.getStartDate()));
    evt.put("endDate", fmt.print(event.getEndDate()));
    evt.put("location", StringUtils.defaultIfBlank(event.getLocation(), null));
    evt.put("locationUrl", TplHelper.buildGoogleMapsUrl(event.getLocation()));
    evt.put("organizer", StringUtils.defaultIfBlank(event.getOrganizerCN(), event.getOrganizerAddress()));

    MapItemList evtAtts = new MapItemList();
    for (EventAttendee attendee : event.getAttendees()) {
        MapItem item = new MapItem();
        String cn = attendee.getCN();
        String address = attendee.getAddress();
        item.put("cn", StringUtils.isBlank(cn) ? null : cn);
        item.put("address", StringUtils.isBlank(address) ? null : address);
        evtAtts.add(item);//from  w w  w . j ava2 s.co  m
    }

    MapItem vars = new MapItem();
    vars.put("i18n", i18n);
    vars.put("event", evt);
    vars.put("eventAttendees", evtAtts);

    return WT.buildTemplate(SERVICE_ID, "tpl/email/eventInvitation-body.html", vars);
}

From source file:com.sonicle.webtop.core.bol.js.JsReminderInApp.java

License:Open Source License

public JsReminderInApp(ReminderInApp rem) {
    //DateTimeFormatter ymdhmsFmt = DateTimeUtils.createYmdHmsFormatter(DateTimeZone.forID(rem.getTimezone()));
    DateTimeZone tz = DateTimeZone.forID(rem.getTimezone());
    serviceId = rem.getServiceId();/*  w ww. ja v  a2s  .com*/
    type = rem.getType();
    instanceId = rem.getInstanceId();
    title = rem.getTitle();
    date = DateTimeUtils.printYmdHmsWithZone(rem.getDate(), tz);
    //if(rem.getDate() != null) date = ymdhmsFmt.print(rem.getDate());
    timezone = rem.getTimezone();
}

From source file:com.sonicle.webtop.core.bol.js.JsReminderInApp.java

License:Open Source License

public JsReminderInApp(OSnoozedReminder rem) {
    //DateTimeFormatter ymdhmsFmt = DateTimeUtils.createYmdHmsFormatter(rem.getDateTimeZone());
    DateTimeZone tz = DateTimeZone.forID(rem.getTimezone());
    serviceId = rem.getServiceId();//from w w w.  j a  v  a2  s.  c  o m
    type = rem.getType();
    instanceId = rem.getInstanceId();
    title = rem.getTitle();
    date = DateTimeUtils.printYmdHmsWithZone(rem.getDate(), tz);
    //if(rem.getDate() != null) date = ymdhmsFmt.print(rem.getDate());
    timezone = rem.getTimezone();
}

From source file:com.sonicle.webtop.core.bol.js.JsReminderInApp.java

License:Open Source License

public static ReminderInApp createReminderInApp(UserProfileId profileId, JsReminderInApp js) {
    ReminderInApp rem = new ReminderInApp(js.serviceId, profileId, js.type, js.instanceId);
    rem.setTitle(js.title);/*from w  ww .j  av a  2  s.  c  o m*/
    rem.setDate(DateTimeUtils.parseYmdHmsWithZone(js.date, DateTimeZone.forID(js.timezone)));
    rem.setTimezone(js.timezone);
    return rem;
}

From source file:com.sos.hibernate.classes.UtcTimeHelper.java

License:Apache License

public static String convertTimeZonesToString(String dateFormat, String fromTimeZone, String toTimeZone,
        DateTime fromDateTime) {/* www. j av  a2s . c om*/
    DateTimeZone fromZone = DateTimeZone.forID(fromTimeZone);
    DateTimeZone toZone = DateTimeZone.forID(toTimeZone);

    DateTime dateTime = new DateTime(fromDateTime);

    dateTime = dateTime.withZoneRetainFields(fromZone);

    DateTime toDateTime = new DateTime(dateTime).withZone(toZone);

    DateTimeFormatter oFormatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'H:mm:ss.SSSZ");
    DateTimeFormatter oFormatter2 = DateTimeFormat.forPattern(dateFormat);

    DateTime newDate = oFormatter.withOffsetParsed().parseDateTime(toDateTime.toString());

    return oFormatter2.withZone(toZone).print(newDate.getMillis());

}