Example usage for java.util TimeZone SHORT

List of usage examples for java.util TimeZone SHORT

Introduction

In this page you can find the example usage for java.util TimeZone SHORT.

Prototype

int SHORT

To view the source code for java.util TimeZone SHORT.

Click Source Link

Document

A style specifier for getDisplayName() indicating a short name, such as "PST."

Usage

From source file:org.apache.oozie.servlet.BaseAdminServlet.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private JSONArray availableTimeZonesToJsonArray() {
    JSONArray array = new JSONArray();
    for (String tzId : TimeZone.getAvailableIDs()) {
        // skip id's that are like "Etc/GMT+01:00" because their display names are like "GMT-01:00", which is confusing
        if (!tzId.startsWith("Etc/GMT")) {
            JSONObject json = new JSONObject();
            TimeZone tZone = TimeZone.getTimeZone(tzId);
            json.put(JsonTags.TIME_ZOME_DISPLAY_NAME,
                    tZone.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
            json.put(JsonTags.TIME_ZONE_ID, tzId);
            array.add(json);/*from   w  w  w .  j ava  2  s  . c o  m*/
        }
    }

    // The combo box this populates cannot be edited, so the user can't type in GMT offsets (like in the CLI), so we'll add
    // in some hourly offsets here (though the user will not be able to use other offsets without editing the cookie manually
    // and they are not in order)
    array.addAll(GMTOffsetTimeZones);

    return array;
}

From source file:com.collabnet.ccf.pi.qc.v90.QCHandler.java

/**
 * Gets the value of the field in a suitable data type.
 * /*from  w ww .ja  va2  s.c  o m*/
 */
public String getProperFieldValue(GenericArtifactField thisField, String targetSystemTimezone) {

    String fieldValue = null;
    GenericArtifactField.FieldValueTypeValue fieldValueTypeValue = thisField.getFieldValueType();
    switch (fieldValueTypeValue) {
    case DATE: {
        GregorianCalendar gcal = (GregorianCalendar) thisField.getFieldValue();
        if (gcal != null) {
            Date targetTimezoneDate = gcal.getTime();
            if (DateUtil.isAbsoluteDateInTimezone(targetTimezoneDate, DateUtil.GMT_TIME_ZONE_STRING)) {
                targetTimezoneDate = DateUtil.convertGMTToTimezoneAbsoluteDate(targetTimezoneDate,
                        TimeZone.getDefault().getDisplayName(false, TimeZone.SHORT));
            }
            fieldValue = DateUtil.formatQCDate(targetTimezoneDate);
        }
        break;
    }
    case DATETIME: {
        Date targetTimezoneDate = (Date) thisField.getFieldValue();
        if (targetTimezoneDate != null) {
            fieldValue = DateUtil.formatQCDate(targetTimezoneDate);
        }
        break;
    }

    }
    return fieldValue;

}

From source file:DateFormatUtils.java

/**
 * <p>Returns a list of Rules given a pattern.</p>
 * //from   www . ja  v  a  2 s  . c o m
 * @return a <code>List</code> of Rule objects
 * @throws IllegalArgumentException if pattern is invalid
 */
protected List parsePattern() {
    DateFormatSymbols symbols = new DateFormatSymbols(mLocale);
    List rules = new ArrayList();

    String[] ERAs = symbols.getEras();
    String[] months = symbols.getMonths();
    String[] shortMonths = symbols.getShortMonths();
    String[] weekdays = symbols.getWeekdays();
    String[] shortWeekdays = symbols.getShortWeekdays();
    String[] AmPmStrings = symbols.getAmPmStrings();

    int length = mPattern.length();
    int[] indexRef = new int[1];

    for (int i = 0; i < length; i++) {
        indexRef[0] = i;
        String token = parseToken(mPattern, indexRef);
        i = indexRef[0];

        int tokenLen = token.length();
        if (tokenLen == 0) {
            break;
        }

        Rule rule;
        char c = token.charAt(0);

        switch (c) {
        case 'G': // era designator (text)
            rule = new TextField(Calendar.ERA, ERAs);
            break;
        case 'y': // year (number)
            if (tokenLen >= 4) {
                rule = selectNumberRule(Calendar.YEAR, tokenLen);
            } else {
                rule = TwoDigitYearField.INSTANCE;
            }
            break;
        case 'M': // month in year (text and number)
            if (tokenLen >= 4) {
                rule = new TextField(Calendar.MONTH, months);
            } else if (tokenLen == 3) {
                rule = new TextField(Calendar.MONTH, shortMonths);
            } else if (tokenLen == 2) {
                rule = TwoDigitMonthField.INSTANCE;
            } else {
                rule = UnpaddedMonthField.INSTANCE;
            }
            break;
        case 'd': // day in month (number)
            rule = selectNumberRule(Calendar.DAY_OF_MONTH, tokenLen);
            break;
        case 'h': // hour in am/pm (number, 1..12)
            rule = new TwelveHourField(selectNumberRule(Calendar.HOUR, tokenLen));
            break;
        case 'H': // hour in day (number, 0..23)
            rule = selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen);
            break;
        case 'm': // minute in hour (number)
            rule = selectNumberRule(Calendar.MINUTE, tokenLen);
            break;
        case 's': // second in minute (number)
            rule = selectNumberRule(Calendar.SECOND, tokenLen);
            break;
        case 'S': // millisecond (number)
            rule = selectNumberRule(Calendar.MILLISECOND, tokenLen);
            break;
        case 'E': // day in week (text)
            rule = new TextField(Calendar.DAY_OF_WEEK, tokenLen < 4 ? shortWeekdays : weekdays);
            break;
        case 'D': // day in year (number)
            rule = selectNumberRule(Calendar.DAY_OF_YEAR, tokenLen);
            break;
        case 'F': // day of week in month (number)
            rule = selectNumberRule(Calendar.DAY_OF_WEEK_IN_MONTH, tokenLen);
            break;
        case 'w': // week in year (number)
            rule = selectNumberRule(Calendar.WEEK_OF_YEAR, tokenLen);
            break;
        case 'W': // week in month (number)
            rule = selectNumberRule(Calendar.WEEK_OF_MONTH, tokenLen);
            break;
        case 'a': // am/pm marker (text)
            rule = new TextField(Calendar.AM_PM, AmPmStrings);
            break;
        case 'k': // hour in day (1..24)
            rule = new TwentyFourHourField(selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen));
            break;
        case 'K': // hour in am/pm (0..11)
            rule = selectNumberRule(Calendar.HOUR, tokenLen);
            break;
        case 'z': // time zone (text)
            if (tokenLen >= 4) {
                rule = new TimeZoneNameRule(mTimeZone, mTimeZoneForced, mLocale, TimeZone.LONG);
            } else {
                rule = new TimeZoneNameRule(mTimeZone, mTimeZoneForced, mLocale, TimeZone.SHORT);
            }
            break;
        case 'Z': // time zone (value)
            if (tokenLen == 1) {
                rule = TimeZoneNumberRule.INSTANCE_NO_COLON;
            } else {
                rule = TimeZoneNumberRule.INSTANCE_COLON;
            }
            break;
        case '\'': // literal text
            String sub = token.substring(1);
            if (sub.length() == 1) {
                rule = new CharacterLiteral(sub.charAt(0));
            } else {
                rule = new StringLiteral(sub);
            }
            break;
        default:
            throw new IllegalArgumentException("Illegal pattern component: " + token);
        }

        rules.add(rule);
    }

    return rules;
}

From source file:com.android.calendar.AllInOneActivity.java

private void updateSecondaryTitleFields(long visibleMillisSinceEpoch) {
    mShowWeekNum = Utils.getShowWeekNumber(this);
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    if (visibleMillisSinceEpoch != -1) {
        int weekNum = Utils.getWeekNumberFromTime(visibleMillisSinceEpoch, this);
        mWeekNum = weekNum;/*from w w  w . j av  a 2 s .  c  om*/
    }

    if (mShowWeekNum && (mCurrentView == ViewType.WEEK) && mIsTabletConfig && mWeekTextView != null) {
        String weekString = getResources().getQuantityString(R.plurals.weekN, mWeekNum, mWeekNum);
        mWeekTextView.setText(weekString);
        mWeekTextView.setVisibility(View.VISIBLE);
    } else if (visibleMillisSinceEpoch != -1 && mWeekTextView != null && mCurrentView == ViewType.DAY
            && mIsTabletConfig) {
        Time time = new Time(mTimeZone);
        time.set(visibleMillisSinceEpoch);
        int julianDay = Time.getJulianDay(visibleMillisSinceEpoch, time.gmtoff);
        time.setToNow();
        int todayJulianDay = Time.getJulianDay(time.toMillis(false), time.gmtoff);
        String dayString = Utils.getDayOfWeekString(julianDay, todayJulianDay, visibleMillisSinceEpoch, this);
        mWeekTextView.setText(dayString);
        mWeekTextView.setVisibility(View.VISIBLE);
    } else if (mWeekTextView != null && (!mIsTabletConfig || mCurrentView != ViewType.DAY)) {
        mWeekTextView.setVisibility(View.GONE);
    }

    if (mHomeTime != null
            && (mCurrentView == ViewType.DAY || mCurrentView == ViewType.WEEK
                    || mCurrentView == ViewType.AGENDA)
            && !TextUtils.equals(mTimeZone, Time.getCurrentTimezone())) {
        Time time = new Time(mTimeZone);
        time.setToNow();
        long millis = time.toMillis(true);
        boolean isDST = time.isDst != 0;
        int flags = DateUtils.FORMAT_SHOW_TIME;
        if (DateFormat.is24HourFormat(this)) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        // Formats the time as
        String timeString = (new StringBuilder(Utils.formatDateRange(this, millis, millis, flags))).append(" ")
                .append(TimeZone.getTimeZone(mTimeZone).getDisplayName(isDST, TimeZone.SHORT,
                        Locale.getDefault()))
                .toString();
        mHomeTime.setText(timeString);
        mHomeTime.setVisibility(View.VISIBLE);
        // Update when the minute changes
        mHomeTime.removeCallbacks(mHomeTimeUpdater);
        mHomeTime.postDelayed(mHomeTimeUpdater,
                DateUtils.MINUTE_IN_MILLIS - (millis % DateUtils.MINUTE_IN_MILLIS));
    } else if (mHomeTime != null) {
        mHomeTime.setVisibility(View.GONE);
    }
}

From source file:org.sakaiproject.portal.charon.SkinnableCharonPortal.java

public void includeBottom(PortalRenderContext rcontext) {
    if (rcontext.uses(INCLUDE_BOTTOM)) {
        String thisUser = SessionManager.getCurrentSessionUserId();

        //Get user preferences
        PreferencesService preferencesService = (PreferencesService) ComponentManager
                .get(PreferencesService.class);

        Preferences prefs = preferencesService.getPreferences(thisUser);

        boolean showServerTime = ServerConfigurationService.getBoolean("portal.show.time", true);
        if (showServerTime) {
            rcontext.put("showServerTime", "true");
            Calendar now = Calendar.getInstance();
            Date nowDate = new Date(now.getTimeInMillis());

            //first set server date and time
            TimeZone serverTz = TimeZone.getDefault();
            now.setTimeZone(serverTz);/*from   ww w.  j  a v  a  2  s. c om*/

            rcontext.put("serverTzDisplay",
                    serverTz.getDisplayName(serverTz.inDaylightTime(nowDate), TimeZone.SHORT));

            rcontext.put("serverTzGMTOffset", String.valueOf(
                    now.getTimeInMillis() + now.get(Calendar.ZONE_OFFSET) + now.get(Calendar.DST_OFFSET)));

            //provide the user's preferred timezone information if it is different

            //Get the Properties object that holds user's TimeZone preferences 
            ResourceProperties tzprops = prefs.getProperties(TimeService.APPLICATION_ID);

            //Get the ID of the timezone using the timezone key.
            //Default to 'localTimeZone' (server timezone?)
            String preferredTzId = (String) tzprops.get(TimeService.TIMEZONE_KEY);

            if (preferredTzId != null && !preferredTzId.equals(serverTz.getID())) {
                TimeZone preferredTz = TimeZone.getTimeZone(preferredTzId);

                now.setTimeZone(preferredTz);

                rcontext.put("showPreferredTzTime", "true");

                //now set up the portal information
                rcontext.put("preferredTzDisplay",
                        preferredTz.getDisplayName(preferredTz.inDaylightTime(nowDate), TimeZone.SHORT));

                rcontext.put("preferredTzGMTOffset", String.valueOf(
                        now.getTimeInMillis() + now.get(Calendar.ZONE_OFFSET) + now.get(Calendar.DST_OFFSET)));
            } else {
                rcontext.put("showPreferredTzTime", "false");
            }
        }

        rcontext.put("pagepopup", false);

        String copyright = ServerConfigurationService.getString("bottom.copyrighttext");

        /**
         * Replace keyword in copyright message from sakai.properties 
         * with the server's current year to auto-update of Copyright end date 
         */
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
        String currentServerYear = simpleDateFormat.format(new Date());
        copyright = copyright.replaceAll(SERVER_COPYRIGHT_CURRENT_YEAR_KEYWORD, currentServerYear);

        String service = ServerConfigurationService.getString("ui.service", "Sakai");
        String serviceVersion = ServerConfigurationService.getString("version.service", "?");
        String sakaiVersion = ServerConfigurationService.getString("version.sakai", "?");
        String server = ServerConfigurationService.getServerId();
        String[] bottomNav = ServerConfigurationService.getStrings("bottomnav");
        String[] poweredByUrl = ServerConfigurationService.getStrings("powered.url");
        String[] poweredByImage = ServerConfigurationService.getStrings("powered.img");
        String[] poweredByAltText = ServerConfigurationService.getStrings("powered.alt");

        {
            List<Object> l = new ArrayList<Object>();
            if ((bottomNav != null) && (bottomNav.length > 0)) {
                for (int i = 0; i < bottomNav.length; i++) {
                    l.add(bottomNav[i]);
                }
            }
            rcontext.put("bottomNav", l);
        }

        boolean neoChatAvailable = ServerConfigurationService.getBoolean("portal.neochat", true)
                && chatHelper.checkChatPermitted(thisUser);

        rcontext.put("neoChat", neoChatAvailable);
        rcontext.put("portalChatPollInterval",
                ServerConfigurationService.getInt("portal.chat.pollInterval", 5000));
        rcontext.put("neoAvatar", ServerConfigurationService.getBoolean("portal.neoavatar", true));
        rcontext.put("neoChatVideo", ServerConfigurationService.getBoolean("portal.chat.video", true));
        rcontext.put("portalVideoChatTimeout",
                ServerConfigurationService.getInt("portal.chat.video.timeout", 25));

        if (sakaiTutorialEnabled && thisUser != null) {
            if (!("1".equals(prefs.getProperties().getProperty("sakaiTutorialFlag")))) {
                rcontext.put("tutorial", true);
                //now save this in the user's prefefences so we don't show it again
                PreferencesEdit preferences = null;
                SecurityAdvisor secAdv = null;
                try {
                    secAdv = new SecurityAdvisor() {
                        @Override
                        public SecurityAdvice isAllowed(String userId, String function, String reference) {
                            if ("prefs.add".equals(function) || "prefs.upd".equals(function)) {
                                return SecurityAdvice.ALLOWED;
                            }
                            return null;
                        }
                    };
                    securityService.pushAdvisor(secAdv);

                    try {
                        preferences = preferencesService.edit(thisUser);
                    } catch (IdUnusedException ex1) {
                        try {
                            preferences = preferencesService.add(thisUser);
                        } catch (IdUsedException ex2) {
                            M_log.error(ex2);
                        } catch (PermissionException ex3) {
                            M_log.error(ex3);
                        }
                    }
                    if (preferences != null) {
                        ResourcePropertiesEdit props = preferences.getPropertiesEdit();
                        props.addProperty("sakaiTutorialFlag", "1");
                        preferencesService.commit(preferences);
                    }
                } catch (Exception e1) {
                    M_log.error(e1);
                } finally {
                    if (secAdv != null) {
                        securityService.popAdvisor(secAdv);
                    }
                }
            }
        }
        // rcontext.put("bottomNavSitNewWindow",
        // Web.escapeHtml(rb.getString("site_newwindow")));

        if ((poweredByUrl != null) && (poweredByImage != null) && (poweredByAltText != null)
                && (poweredByUrl.length == poweredByImage.length)
                && (poweredByUrl.length == poweredByAltText.length)) {
            {
                List<Object> l = new ArrayList<Object>();
                for (int i = 0; i < poweredByUrl.length; i++) {
                    Map<String, Object> m = new HashMap<String, Object>();
                    m.put("poweredByUrl", poweredByUrl[i]);
                    m.put("poweredByImage", poweredByImage[i]);
                    m.put("poweredByAltText", poweredByAltText[i]);
                    l.add(m);
                }
                rcontext.put("bottomNavPoweredBy", l);

            }
        } else {
            List<Object> l = new ArrayList<Object>();
            Map<String, Object> m = new HashMap<String, Object>();
            m.put("poweredByUrl", "http://sakaiproject.org");
            m.put("poweredByImage", "/library/image/sakai_powered.gif");
            m.put("poweredByAltText", "Powered by Sakai");
            l.add(m);
            rcontext.put("bottomNavPoweredBy", l);
        }

        rcontext.put("bottomNavService", service);
        rcontext.put("bottomNavCopyright", copyright);
        rcontext.put("bottomNavServiceVersion", serviceVersion);
        rcontext.put("bottomNavSakaiVersion", sakaiVersion);
        rcontext.put("bottomNavServer", server);

        // SAK-25931 - Do not remove this from session here - removal is done by /direct
        Session s = SessionManager.getCurrentSession();
        String userWarning = (String) s.getAttribute("userWarning");
        rcontext.put("userWarning", new Boolean(StringUtils.isNotEmpty(userWarning)));

        if (ServerConfigurationService.getBoolean("pasystem.enabled", false)) {
            PASystem paSystem = (PASystem) ComponentManager.get(PASystem.class);
            rcontext.put("paSystemEnabled", true);
            rcontext.put("paSystem", paSystem);
        }
    }
}

From source file:com.android.calendar.event.EditEventView.java

/**
 * Checks if the start and end times for this event should be displayed in
 * the Calendar app's time zone as well and formats and displays them.
 *///w  ww. j  a v  a  2  s . com
private void updateHomeTime() {
    String tz = Utils.getTimeZone(mActivity, null);
    if (!mAllDayCheckBox.isChecked() && !TextUtils.equals(tz, mTimezone)
            && mModification != EditEventHelper.MODIFY_UNINITIALIZED) {
        int flags = DateUtils.FORMAT_SHOW_TIME;
        boolean is24Format = DateFormat.is24HourFormat(mActivity);
        if (is24Format) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        long millisStart = mStartTime.toMillis(false);
        long millisEnd = mEndTime.toMillis(false);

        boolean isDSTStart = mStartTime.isDst != 0;
        boolean isDSTEnd = mEndTime.isDst != 0;

        // First update the start date and times
        String tzDisplay = TimeZone.getTimeZone(tz).getDisplayName(isDSTStart, TimeZone.SHORT,
                Locale.getDefault());
        StringBuilder time = new StringBuilder();

        mSB.setLength(0);
        time.append(DateUtils.formatDateRange(mActivity, mF, millisStart, millisStart, flags, tz)).append(" ")
                .append(tzDisplay);
        mStartTimeHome.setText(time.toString());

        flags = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
                | DateUtils.FORMAT_SHOW_WEEKDAY;
        mSB.setLength(0);
        mStartDateHome.setText(
                DateUtils.formatDateRange(mActivity, mF, millisStart, millisStart, flags, tz).toString());

        // Make any adjustments needed for the end times
        if (isDSTEnd != isDSTStart) {
            tzDisplay = TimeZone.getTimeZone(tz).getDisplayName(isDSTEnd, TimeZone.SHORT, Locale.getDefault());
        }
        flags = DateUtils.FORMAT_SHOW_TIME;
        if (is24Format) {
            flags |= DateUtils.FORMAT_24HOUR;
        }

        // Then update the end times
        time.setLength(0);
        mSB.setLength(0);
        time.append(DateUtils.formatDateRange(mActivity, mF, millisEnd, millisEnd, flags, tz)).append(" ")
                .append(tzDisplay);
        mEndTimeHome.setText(time.toString());

        flags = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
                | DateUtils.FORMAT_SHOW_WEEKDAY;
        mSB.setLength(0);
        mEndDateHome
                .setText(DateUtils.formatDateRange(mActivity, mF, millisEnd, millisEnd, flags, tz).toString());

        mStartHomeGroup.setVisibility(View.VISIBLE);
        mEndHomeGroup.setVisibility(View.VISIBLE);
    } else {
        mStartHomeGroup.setVisibility(View.GONE);
        mEndHomeGroup.setVisibility(View.GONE);
    }
}

From source file:org.sakaiproject.calendar.tool.CalendarAction.java

public String buildMainPanelContext(VelocityPortlet portlet, Context context, RunData runData,
        SessionState sstate) {//from   w  w w  .j  ava 2 s .co m
    CalendarActionState state = (CalendarActionState) getState(portlet, runData, CalendarActionState.class);

    String template = (String) getContext(runData).get("template");

    // get current state (view); if not set use tool default or default to week view
    String stateName = state.getState();
    if (stateName == null) {
        stateName = portlet.getPortletConfig().getInitParameter(PORTLET_CONFIG_DEFAULT_VIEW);
        if (stateName == null)
            stateName = ServerConfigurationService.getString("calendar.default.view", "week");
        state.setState(stateName);
    }

    if (stateName.equals(STATE_SCHEDULE_IMPORT)) {
        buildImportContext(portlet, context, runData, state, getSessionState(runData));
    } else if (stateName.equals(STATE_MERGE_CALENDARS)) {
        // build the context to display the options panel
        mergedCalendarPage.buildContext(portlet, context, runData, state, getSessionState(runData));
    } else if (stateName.equals(STATE_CALENDAR_SUBSCRIPTIONS)) {
        // build the context to display the options panel
        calendarSubscriptionsPage.buildContext(portlet, context, runData, state, getSessionState(runData));
    } else if (stateName.equals(STATE_CUSTOMIZE_CALENDAR)) {
        // build the context to display the options panel
        //needed to track when user clicks 'Save' or 'Cancel'
        String sstatepage = "";

        Object statepageAttribute = sstate.getAttribute(SSTATE_ATTRIBUTE_ADDFIELDS_PAGE);

        if (statepageAttribute != null) {
            sstatepage = statepageAttribute.toString();
        }

        if (!sstatepage.equals(PAGE_ADDFIELDS)) {
            sstate.setAttribute(SSTATE_ATTRIBUTE_ADDFIELDS_PAGE, PAGE_MAIN);
        }

        customizeCalendarPage.buildContext(portlet, context, runData, state, getSessionState(runData));
    } else if ((stateName.equals("revise")) || (stateName.equals("goToReviseCalendar"))) {
        // build the context for the normal view show
        buildReviseContext(portlet, context, runData, state);
    } else if (stateName.equals("description")) {
        // build the context for the basic step of adding file
        buildDescriptionContext(portlet, context, runData, state);
    } else if (stateName.equals("year")) {
        // build the context for the advanced step of adding file
        buildYearContext(portlet, context, runData, state);
    } else if (stateName.equals("month")) {
        // build the context for the basic step of adding folder
        buildMonthContext(portlet, context, runData, state);
    } else if (stateName.equals("day")) {
        // build the context for the basic step of adding simple text
        buildDayContext(portlet, context, runData, state);
    } else if (stateName.equals("week")) {
        // build the context for the basic step of delete confirm page
        buildWeekContext(portlet, context, runData, state);
    } else if (stateName.equals("new")) {
        // build the context to display the property list
        buildNewContext(portlet, context, runData, state);
    } else if (stateName.equals("icalEx")) {
        buildIcalExportPanelContext(portlet, context, runData, state);
    } else if (stateName.equals("opaqueUrlClean")) {
        buildOpaqueUrlCleanContext(portlet, context, runData, state);
    } else if (stateName.equals("opaqueUrlExisting")) {
        buildOpaqueUrlExistingContext(portlet, context, runData, state);
    } else if (stateName.equals("delete")) {
        // build the context to display the property list
        buildDeleteContext(portlet, context, runData, state);
    } else if (stateName.equals("list")) {
        // build the context to display the list view
        buildListContext(portlet, context, runData, state);
    } else if (stateName.equals(STATE_SET_FREQUENCY)) {
        buildFrequencyContext(portlet, context, runData, state);
    }

    if (stateName.equals("description") || stateName.equals("year") || stateName.equals("month")
            || stateName.equals("day") || stateName.equals("week") || stateName.equals("list")) {
        // SAK-23566 capture the view calendar events
        EventTrackingService ets = (EventTrackingService) ComponentManager.get(EventTrackingService.class);
        String calendarRef = state.getPrimaryCalendarReference();
        if (ets != null && calendarRef != null) {
            // need to cleanup the cal references which look like /calendar/calendar/4ea74c4d-3f9e-4c32-b03f-15e7915e6051/main
            String eventRef = StringUtils.replace(calendarRef, "/main", "/" + stateName);
            String calendarEventId = state.getCalendarEventId();
            if (StringUtils.isNotBlank(calendarEventId)) {
                eventRef += "/" + calendarEventId;
            }
            ets.post(ets.newEvent("calendar.read", eventRef, false));
        }
    }

    TimeZone timeZone = TimeService.getLocalTimeZone();
    context.put("timezone", timeZone.getDisplayName(timeZone.inDaylightTime(new Date()), TimeZone.SHORT));

    //the AM/PM strings
    context.put("amString", CalendarUtil.getLocalAMString());
    context.put("pmString", CalendarUtil.getLocalPMString());

    // group realted variables
    context.put("siteAccess", CalendarEvent.EventAccess.SITE);
    context.put("groupAccess", CalendarEvent.EventAccess.GROUPED);

    context.put("message", state.getState());
    context.put("state", state.getKey());
    context.put("tlang", rb);
    context.put("config", configProps);
    context.put("dateFormat", getDateFormatString());
    context.put("timeFormat", getTimeFormatString());

    return template;

}

From source file:org.apache.oozie.cli.OozieCLI.java

private void printAvailableTimeZones() {
    System.out.println("The format is \"SHORT_NAME (ID)\"\nGive the ID to the -timezone argument");
    System.out.println("GMT offsets can also be used (e.g. GMT-07:00, GMT-0700, GMT+05:30, GMT+0530)");
    System.out.println("Available Time Zones:");
    for (String tzId : TimeZone.getAvailableIDs()) {
        // skip id's that are like "Etc/GMT+01:00" because their display names are like "GMT-01:00", which is confusing
        if (!tzId.startsWith("Etc/GMT")) {
            TimeZone tZone = TimeZone.getTimeZone(tzId);
            System.out.println("      " + tZone.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
        }//from w w  w .j a va 2 s.c  om
    }
}