Example usage for java.text DateFormat SHORT

List of usage examples for java.text DateFormat SHORT

Introduction

In this page you can find the example usage for java.text DateFormat SHORT.

Prototype

int SHORT

To view the source code for java.text DateFormat SHORT.

Click Source Link

Document

Constant for short style pattern.

Usage

From source file:org.helianto.core.domain.IdentitySecurity.java

public String getExpirationDateAsString() {
    if (getExpirationDate() == null) {
        return "";
    }/*from  w  w w  .ja va  2 s.co m*/
    DateFormat formatter = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
    return formatter.format(getExpirationDate());
}

From source file:org.sipfoundry.sipxconfig.components.TapestryUtils.java

public static DateFormat getDateFormat(Locale locale) {
    return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
}

From source file:org.sakaiproject.poll.model.Poll.java

private static DateFormat getDateFormatForXML() {
    return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
}

From source file:fr.kwiatkowski.apktrack.ui.AppViewHolder.java

/**
 * Sets the last check date of the application and its update source on the third line.
 * @param app The app whose information is to be displayed.
 * @param ctx The context of the application
 *//*  w w  w. ja va2 s.co m*/
private void _set_date(InstalledApp app, Context ctx) {
    String update_source = app.get_update_source();
    if (app.get_last_check_date() == null) {
        _check_date.setText(String.format(update_source == null ? "%s %s." : "[" + update_source + "] %s %s.",
                ctx.getResources().getString(R.string.last_check),
                ctx.getResources().getString(R.string.never)));
        _check_date.setTextColor(Color.GRAY);
    } else {
        DateFormat sdf = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
        _check_date.setText(String.format(update_source == null ? "%s %s." : "[" + update_source + "] %s %s.",
                ctx.getResources().getString(R.string.last_check), sdf.format(app.get_last_check_date())));
        _check_date.setTextColor(_default_color);
    }
}

From source file:org.duniter.elasticsearch.synchro.SynchroService.java

public SynchroResult synchronizePeer(final Peer peer, boolean enableSynchroWebsocket) {
    long startExecutionTime = System.currentTimeMillis();

    // Check if peer alive and valid
    boolean isAliveAndValid = isAliveAndValid(peer);
    if (!isAliveAndValid) {
        logger.warn(String.format("[%s] [%s] Not reachable, or not running on this currency. Skipping.",
                peer.getCurrency(), peer));
        return null;
    }/*from   w ww  .j a  v  a2 s  .  c om*/

    SynchroResult result = new SynchroResult();

    // Get the last execution time (or 0 is never synchronized)
    // If not the first synchro, add a delay to last execution time
    // to avoid missing data because incorrect clock configuration
    long lastExecutionTime = forceFullResync ? 0 : getLastExecutionTime(peer);
    if (logger.isDebugEnabled() && lastExecutionTime > 0) {
        logger.debug(String.format(
                "[%s] [%s] Found last synchronization execution at {%s}. Will apply time offset of {-%s ms}",
                peer.getCurrency(), peer, DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM)
                        .format(new Date(lastExecutionTime * 1000)),
                pluginSettings.getSynchroTimeOffset()));
    }

    final long fromTime = lastExecutionTime > 0 ? lastExecutionTime - pluginSettings.getSynchroTimeOffset() : 0;

    if (logger.isInfoEnabled()) {
        if (fromTime == 0) {
            logger.info(String.format("[%s] [%s] Synchronization {ALL}...", peer.getCurrency(), peer));
        } else {
            logger.info(String.format("[%s] [%s] Synchronization delta since {%s}...", peer.getCurrency(), peer,
                    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM)
                            .format(new Date(fromTime * 1000))));
        }
    }

    // Execute actions
    List<SynchroAction> executedActions = actions.stream()
            .filter(a -> a.getEndPointApi().name().equals(peer.getApi())).map(a -> {
                try {
                    a.handleSynchronize(peer, fromTime, result);
                } catch (Exception e) {
                    logger.error(String.format("[%s] [%s] Failed to execute synchro action: %s",
                            peer.getCurrency(), peer, e.getMessage()), e);
                }
                return a;
            }).collect(Collectors.toList());

    if (logger.isDebugEnabled()) {
        logger.debug(String.format("[%s] [%s] Synchronized in %s ms: %s", peer.getCurrency(), peer,
                System.currentTimeMillis() - startExecutionTime, result.toString()));
    }

    saveExecution(peer, result, startExecutionTime);

    // Start listen changes on this peer
    if (enableSynchroWebsocket) {
        startListenChangesOnPeer(peer, executedActions);
    }

    return result;
}

From source file:org.apache.ddlutils.platform.SqlBuilder.java

/**
 * Sets the locale that is used for number and date formatting
 * (when printing default values and in generates insert/update/delete
 * statements)./*from   ww w  .  j  a  va2s  .co  m*/
 *
 * @param localeStr The new locale or <code>null</code> if default formatting
 *                  should be used; Format is "language[_country[_variant]]"
 */
public void setValueLocale(String localeStr) {
    if (localeStr != null) {
        int sepPos = localeStr.indexOf('_');
        String language = null;
        String country = null;
        String variant = null;

        if (sepPos > 0) {
            language = localeStr.substring(0, sepPos);
            country = localeStr.substring(sepPos + 1);
            sepPos = country.indexOf('_');
            if (sepPos > 0) {
                variant = country.substring(sepPos + 1);
                country = country.substring(0, sepPos);
            }
        } else {
            language = localeStr;
        }
        if (language != null) {
            Locale locale = null;

            if (variant != null) {
                locale = new Locale(language, country, variant);
            } else if (country != null) {
                locale = new Locale(language, country);
            } else {
                locale = new Locale(language);
            }

            _valueLocale = localeStr;
            setValueDateFormat(DateFormat.getDateInstance(DateFormat.SHORT, locale));
            setValueTimeFormat(DateFormat.getTimeInstance(DateFormat.SHORT, locale));
            setValueNumberFormat(NumberFormat.getNumberInstance(locale));
            return;
        }
    }
    _valueLocale = null;
    setValueDateFormat(null);
    setValueTimeFormat(null);
    setValueNumberFormat(null);
}

From source file:org.grails.web.pages.GroovyPageWritable.java

protected Writer doWriteTo(Writer out) throws IOException {
    if (showSource) {
        // Set it to TEXT
        response.setContentType(GROOVY_SOURCE_CONTENT_TYPE); // must come before response.getOutputStream()
        writeGroovySourceToResponse(metaInfo, out);
    } else {//from   w  w w . j  a  v a  2s .  co  m
        // Set it to HTML by default
        if (metaInfo.getCompilationException() != null) {
            throw metaInfo.getCompilationException();
        }

        // Set up the script context
        TemplateVariableBinding parentBinding = null;
        boolean hasRequest = request != null;
        boolean newParentCreated = false;

        if (hasRequest) {
            parentBinding = (TemplateVariableBinding) request
                    .getAttribute(GrailsApplicationAttributes.PAGE_SCOPE);
            if (parentBinding == null) {
                if (webRequest != null) {
                    parentBinding = new TemplateVariableBinding(
                            new WebRequestTemplateVariableBinding(webRequest));
                    parentBinding.setRoot(true);
                    newParentCreated = true;
                }
            }
        }

        if (allowSettingContentType && response != null) {
            // only try to set content type when evaluating top level GSP
            boolean contentTypeAlreadySet = response.isCommitted() || response.getContentType() != null;
            if (!contentTypeAlreadySet) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Writing response to [" + response.getClass() + "] with content type: "
                            + metaInfo.getContentType());
                }
                response.setContentType(metaInfo.getContentType()); // must come before response.getWriter()
            }
        }

        GroovyPageBinding binding = createBinding(parentBinding);
        String previousGspCode = GSP_NONE_CODEC_NAME;
        if (hasRequest) {
            request.setAttribute(GrailsApplicationAttributes.PAGE_SCOPE, binding);
            previousGspCode = (String) request.getAttribute(GrailsApplicationAttributes.GSP_CODEC);
        }

        makeLegacyCodecVariablesAvailable(hasRequest, binding);

        binding.setVariableDirectly(GroovyPage.RESPONSE, response);
        binding.setVariableDirectly(GroovyPage.REQUEST, request);
        // support development mode's evaluate (so that doesn't search for missing variable in parent bindings)

        GroovyPage page = null;
        try {
            page = (GroovyPage) metaInfo.getPageClass().newInstance();
        } catch (Exception e) {
            throw new GroovyPagesException("Problem instantiating page class", e);
        }
        page.setBinding(binding);
        binding.setOwner(page);

        page.initRun(out, webRequest, metaInfo);

        int debugId = 0;
        long debugStartTimeMs = 0;
        if (debugTemplates) {
            debugId = debugTemplatesIdCounter.incrementAndGet();
            out.write("<!-- GSP #");
            out.write(String.valueOf(debugId));
            out.write(" START template: ");
            out.write(page.getGroovyPageFileName());
            out.write(" precompiled: ");
            out.write(String.valueOf(metaInfo.isPrecompiledMode()));
            out.write(" lastmodified: ");
            out.write(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                    .format(new Date(metaInfo.getLastModified())));
            out.write(" -->");
            debugStartTimeMs = System.currentTimeMillis();
        }
        try {
            page.run();
        } finally {
            page.cleanup();
            if (hasRequest) {
                if (newParentCreated) {
                    request.removeAttribute(GrailsApplicationAttributes.PAGE_SCOPE);
                } else {
                    request.setAttribute(GrailsApplicationAttributes.PAGE_SCOPE, parentBinding);
                }
                request.setAttribute(GrailsApplicationAttributes.GSP_CODEC,
                        previousGspCode != null ? previousGspCode : GSP_NONE_CODEC_NAME);
            }
        }
        if (debugTemplates) {
            out.write("<!-- GSP #");
            out.write(String.valueOf(debugId));
            out.write(" END template: ");
            out.write(page.getGroovyPageFileName());
            out.write(" rendering time: ");
            out.write(String.valueOf(System.currentTimeMillis() - debugStartTimeMs));
            out.write(" ms -->");
        }
    }
    return out;
}

From source file:com.appeligo.alerts.KeywordAlertChecker.java

public void sendMessages(KeywordAlert keywordAlert, String fragments, Document doc, String messagePrefix) {

    User user = keywordAlert.getUser();/*www . j av  a  2 s  .c  o m*/
    if (user == null) {
        return;
    }
    String programId = doc.get("programID");
    String programTitle = doc.get("programTitle");

    if (log.isDebugEnabled())
        log.debug("keywordAlert: " + keywordAlert.getUserQuery() + ", sending message to "
                + (user == null ? null : user.getUsername()));

    try {
        // Use the user's lineup to determine the start time of this program which might air at different times for diff timezones
        String startTimeString = doc.get("lineup-" + user.getLineupId() + "-startTime");
        if (startTimeString == null) {
            // This user doesn't have the channel or program that our local feed has
            if (log.isDebugEnabled()) {
                String station = doc.get("lineup-" + liveLineup + "-stationName");
                log.debug("No startTime for station " + station + ", program " + programTitle + ", lineup="
                        + user.getLineupId() + ", start time from live lineup="
                        + doc.get("lineup-" + liveLineup + "-startTime"));
            }
            return;
        }
        Date startTime = DateTools.stringToDate(startTimeString);
        Date endTime = DateTools.stringToDate(doc.get("lineup-" + user.getLineupId() + "-endTime"));
        long durationMinutes = (endTime.getTime() - startTime.getTime()) / (60 * 1000);

        Date now = new Date();
        boolean future = endTime.after(now);
        boolean onAirNow = startTime.before(now) && future;
        boolean past = !(future || onAirNow);

        ProgramType programType = ProgramType.fromProgramID(programId);

        boolean uniqueProgram = false;
        if (programType == ProgramType.EPISODE || programType == ProgramType.SPORTS
                || programType == ProgramType.MOVIE) {
            uniqueProgram = true;
        }

        Map<String, String> context = new HashMap<String, String>();

        boolean includeDate;
        DateFormat format;
        if (Math.abs(startTime.getTime() - System.currentTimeMillis()) < 12 * 60 * 60 * 1000) {
            format = DateFormat.getTimeInstance(DateFormat.SHORT);
            includeDate = false;
        } else {
            format = new SimpleDateFormat("EEEE, MMMM d 'at' h:mm a");
            includeDate = true;
        }
        format.setTimeZone(user.getTimeZone());
        context.put("startTime", format.format(startTime));
        if (includeDate) {
            format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
            format.setTimeZone(user.getTimeZone());
        }
        context.put("shortStartTime", format.format(startTime));

        context.put("durationMinutes", Long.toString(durationMinutes));
        // Use the SDTW-C lineup because this is how we know the right channel (station callsign) where we caught the
        // keyword.
        String stationName = doc.get("lineup-" + liveLineup + "-stationName");
        context.put("stationName", stationName);
        boolean sameStation = false;
        if (stationName.equals(doc.get("lineup-" + user.getLineupId() + "-stationName"))) {
            sameStation = true;
        }
        context.put("stationCallSign", doc.get("lineup-" + liveLineup + "-stationCallSign"));

        if (sameStation) {
            if (onAirNow) {
                context.put("timeChannelIntro", "We have been monitoring <b>" + stationName
                        + "</b>, and your topic was recently mentioned on the following program:");
            } else if (future) {
                if (uniqueProgram) {
                    context.put("timeChannelIntro", "We are monitoring <b>" + stationName
                            + "</b>, and your topic will be mentioned on the following program:");
                } else {
                    context.put("timeChannelIntro",
                            "We are monitoring <b>" + stationName + "</b>, and your topic was mentioned on <b>"
                                    + programTitle + "</b>. It may be mentioned when this program airs again:");
                }
            } else {
                context.put("timeChannelIntro", "We have been monitoring <b>" + stationName
                        + "</b>, and your topic was mentioned on a program that aired in your area in the past. "
                        + "You may have an opportunity to see this program in the future:");
            }
        } else {
            if (onAirNow) {
                context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                        + "</b>, and your topic was recently mentioned:");
            } else if (future) {
                if (uniqueProgram) {
                    context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                            + "</b>, and your topic was mentioned.  You may have an opportunity to catch this program when it airs again according to the following schedule:");
                } else {
                    context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                            + "</b>, and your topic was mentioned.  This program will air again as follows, but the topics may or may not be the same:");
                }
            } else {
                context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                        + "</b>, and your topic was mentioned.  However, this program aired in your area in the past. "
                        + "You may have an opportunity to see this program in the future:");
            }
        }
        if (onAirNow) {
            context.put("startsAt", "Started at");
        } else if (future) {
            if (includeDate) {
                context.put("startsAt", "Starts on");
            } else {
                context.put("startsAt", "Starts at");
            }
        } else {
            if (includeDate) {
                context.put("startsAt", "Last aired on");
            } else {
                context.put("startsAt", "Previously aired at");
            }
        }
        context.put("lcStartsAt", context.get("startsAt").toLowerCase());

        String webPath = doc.get("webPath");
        if (webPath == null) {
            webPath = DefaultEpg.getInstance().getProgram(programId).getWebPath();
        }
        if (webPath.charAt(0) == '/') {
            webPath = webPath.substring(1);
        }
        String reducedTitle40 = doc.get("reducedTitle40");
        if (reducedTitle40 == null) {
            reducedTitle40 = DefaultEpg.getInstance().getProgram(programId).getReducedTitle40();
        }
        String programLabel = doc.get("programLabel");
        if (programLabel == null) {
            programLabel = DefaultEpg.getInstance().getProgram(programId).getLabel();
        }
        context.put("programId", programId);
        context.put("webPath", webPath);
        context.put("programLabel", programLabel);
        context.put("reducedTitle40", reducedTitle40);
        if (doc.get("description").trim().length() > 0) {
            context.put("description", "Description: " + doc.get("description") + "<br/>");
        } else {
            context.put("description", "");
        }
        if (fragments == null || fragments.trim().length() == 0) {
            context.put("fragments", "");
        } else {
            context.put("fragments", "Relevant Dialogue: <i>" + fragments + "</i><br/>");
        }
        context.put("query", keywordAlert.getUserQuery());
        context.put("keywordAlertId", Long.toString(keywordAlert.getId()));
        String greeting = user.getUsername();
        context.put("username", greeting);
        String firstName = user.getFirstName();
        if (firstName != null && firstName.trim().length() > 0) {
            greeting = firstName;
        }
        context.put("greeting", greeting);

        format = DateFormat.getTimeInstance(DateFormat.SHORT);
        format.setTimeZone(user.getTimeZone());
        context.put("now", format.format(new Date()));

        ScheduledProgram futureProgram = DefaultEpg.getInstance().getNextShowing(user.getLineupId(), programId,
                false, false);
        if (uniqueProgram) {
            String typeString = null;
            if (programType == ProgramType.EPISODE) {
                typeString = "episode";
            } else if (programType == ProgramType.SPORTS) {
                typeString = "game";
            } else {
                typeString = "movie";
            }
            if (futureProgram != null) {
                String timePreposition = null;
                if ((futureProgram.getStartTime().getTime() - System.currentTimeMillis()) < 12 * 60 * 60
                        * 1000) {
                    timePreposition = "at ";
                    format = DateFormat.getTimeInstance(DateFormat.SHORT);
                } else {
                    timePreposition = "on ";
                    format = new SimpleDateFormat("EEEE, MMMM d 'at' h:mm a");
                }
                format.setTimeZone(user.getTimeZone());
                context.put("rerunInfo", "You can still catch this " + typeString
                        + " in its entirety!  It's scheduled to replay " + timePreposition
                        + format.format(futureProgram.getStartTime()) + " on "
                        + futureProgram.getNetwork().getStationName() + ". Do you want to <a href=\"" + url
                        + webPath + "#addreminder\">set a reminder</a> to be notified the next time this "
                        + typeString + " airs?");
            } else {
                if (programType == ProgramType.SPORTS) {
                    context.put("rerunInfo", "");
                } else {
                    if (onAirNow) {
                        context.put("rerunInfo",
                                "If it's too late to flip on the program now, you can <a href=\"" + url
                                        + webPath
                                        + "#addreminder\">set a reminder</a> to be notified the next time this "
                                        + typeString + " airs.");
                    } else {
                        context.put("rerunInfo",
                                "You can <a href=\"" + url + webPath
                                        + "#addreminder\">set a reminder</a> to be notified the next time this "
                                        + typeString + " airs.");
                    }
                }
            }
        } else {
            if ((futureProgram != null) && futureProgram.isNewEpisode()) {
                context.put("rerunInfo",
                        "The next airing of this show will be new content, and is <i>not a rerun</i>,"
                                + " so these same topics may or may not be discussed."
                                + "  You may still be interested in catching future airings, and you can"
                                + " <a href=\"" + url + webPath
                                + "#addreminder\">set a Flip.TV reminder for this show</a>.");
            } else {
                context.put("rerunInfo",
                        "The broadcaster did not provide enough information to know which future airings,"
                                + " if any, are identical reruns with the same topics mentioned."
                                + "  You may still be interested in catching future airings, and you can"
                                + " <a href=\"" + url + webPath
                                + "#addreminder\">set a Flip.TV reminder for this show</a>.");
            }
        }

        if (keywordAlert.getTodaysAlertCount() == keywordAlert.getMaxAlertsPerDay()) {
            context.put("maxAlertsExceededSentence",
                    "You asked to stop receiving alerts for this topic after receiving "
                            + keywordAlert.getMaxAlertsPerDay()
                            + " alerts in a single day. That limit has been reached. You can change this setting"
                            + " at any time.  Otherwise, we will resume sending alerts"
                            + " for this topic tomorrow.");
        } else {
            context.put("maxAlertsExceededSentence", "");
        }

        if (keywordAlert.isUsingPrimaryEmailRealtime()) {
            Message message = new Message(messagePrefix + "_email", context);
            message.setUser(user);
            message.setTo(user.getPrimaryEmail());
            if (log.isDebugEnabled())
                log.debug("Sending email message to: " + user.getPrimaryEmail());
            message.insert();
        }
        if (keywordAlert.isUsingSMSRealtime() && user.getSmsEmail().trim().length() > 0) {
            Message message = new Message(messagePrefix + "_sms", context);
            message.setTo(user.getSmsEmail());
            message.setUser(user);
            message.setSms(true);
            if (log.isDebugEnabled())
                log.debug("Sending sms message to: " + user.getSmsEmail());
            message.insert();
        }
    } catch (NumberFormatException e) {
        log.error("Couldn't process lucene document for program " + programId, e);
    } catch (MessageContextException e) {
        log.error("Software bug resulted in exception with email message context or configuration", e);
    } catch (ParseException e) {
        log.error(
                "Software bug resulted in exception with document 'startTime' or 'endTime' format in lucene document for program id "
                        + programId,
                e);
    }
}

From source file:org.helianto.core.domain.IdentitySecurity.java

public String getExpirationTimeAsString() {
    if (getExpirationDate() == null) {
        return "";
    }//from w  w w. j av a 2 s.c o  m
    DateFormat formatter = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
    return formatter.format(getExpirationDate());
}

From source file:org.exoplatform.platform.portlet.juzu.calendar.CalendarPortletController.java

@Ajax
@Resource//from w w  w .  j av a  2  s  . c  om
public Response.Content calendarHome() throws Exception {

    displayedCalendar.clear();
    displayedCalendarMap.clear();
    tasksDisplayedList.clear();
    eventsDisplayedList.clear();
    String date_act = null;
    String username = CalendarPortletUtils.getCurrentUser();
    Locale locale = Util.getPortalRequestContext().getLocale();
    String dp = formatDate(locale);
    DateFormat d = new SimpleDateFormat(dp);
    DateFormat dTimezone = DateFormat.getDateInstance(DateFormat.SHORT, locale);
    dTimezone.setCalendar(CalendarPortletUtils.getCurrentCalendar());
    Long date = new Date().getTime();
    int clickNumber = Integer.parseInt(nbclick);
    if (clickNumber != 0)
        date = incDecJour(date, clickNumber);
    Date currentTime = new Date(date);
    // Get Calendar object set to the date and time of the given Date object
    Calendar cal = CalendarPortletUtils.getCurrentCalendar();
    cal.setTime(currentTime);

    // Set time fields to zero
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);

    // Put it back in the Date object
    currentTime = cal.getTime();
    date_act = d.format(currentTime);
    Date comp = currentTime;
    String defaultCalendarLabel = "Default";
    String dateLabel = "";
    try {
        ResourceBundle rs = ResourceBundle.getBundle("locale/portlet/calendar/calendar", locale);
        defaultCalendarLabel = EntityEncoder.FULL.encode(rs.getString("UICalendars.label.defaultCalendarId"));
        if (clickNumber == 0)
            dateLabel = rs.getString("today.label") + ": ";
        else if (clickNumber == -1)
            dateLabel = rs.getString("yesterday.label") + ": ";
        else if (clickNumber == 1)
            dateLabel = rs.getString("tomorrow.label") + ": ";
        else
            dateLabel = "";
    } catch (MissingResourceException ex) {
        if (clickNumber == 0)
            dateLabel = "today.label" + ": ";
        else if (clickNumber == -1)
            dateLabel = "yesterday.label" + ": ";
        else if (clickNumber == 1)
            dateLabel = "tomorrow.label" + ": ";
        else
            dateLabel = "";
    }

    EntityEncoder.FULL.encode(dateLabel);
    dateLabel = new StringBuffer(dateLabel).append(date_act).toString();
    if (nonDisplayedCalendarList == null) {
        SettingValue settingNode = settingService_.get(Context.USER, Scope.APPLICATION,
                CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS);
        if ((settingNode != null) && (settingNode.getValue().toString().split(":").length == 2)) {
            nonDisplayedCalendarList = settingNode.getValue().toString().split(":")[1].split(",");
        }
    }
    List<CalendarEvent> userEvents = getEvents(username, cal);
    if ((userEvents != null) && (!userEvents.isEmpty())) {
        Iterator itr = userEvents.iterator();
        while (itr.hasNext()) {
            CalendarEvent event = (CalendarEvent) itr.next();
            Date from = d.parse(dTimezone.format(event.getFromDateTime()));
            Date to = d.parse(dTimezone.format(event.getToDateTime()));
            if ((event.getEventType().equals(CalendarEvent.TYPE_EVENT))
                    && (from.compareTo(d.parse(dTimezone.format(comp))) <= 0)
                    && (to.compareTo(d.parse(dTimezone.format(comp))) >= 0)) {
                if (!CalendarPortletUtils.contains(nonDisplayedCalendarList, event.getCalendarId())) {
                    org.exoplatform.calendar.service.Calendar calendar = calendarService_
                            .getUserCalendar(username, event.getCalendarId());
                    if (calendar == null) {
                        calendar = calendarService_.getGroupCalendar(event.getCalendarId());
                    }
                    if (calendar.getGroups() == null) {
                        if (calendar.getId().equals(Utils.getDefaultCalendarId(username))
                                && calendar.getName().equals(NewUserListener.defaultCalendarName)) {
                            calendar.setName(defaultCalendarLabel);
                        }
                    }
                    eventsDisplayedList.add(event);
                    if (!displayedCalendarMap.containsKey(calendar.getId())) {
                        displayedCalendarMap.put(calendar.getId(), calendar);
                        displayedCalendar.add(calendar);
                    }
                }
            } else if ((event.getEventType().equals(CalendarEvent.TYPE_TASK))
                    && (((from.compareTo(comp) <= 0) && (to.compareTo(comp) >= 0))
                            || ((event.getEventState().equals(CalendarEvent.NEEDS_ACTION))
                                    && (to.compareTo(comp) < 0)))) {
                tasksDisplayedList.add(event);
            }
        }
        Collections.sort(eventsDisplayedList, eventsComparator);
        Collections.sort(tasksDisplayedList, tasksComparator);
    }
    return calendar.with().set("displayedCalendar", displayedCalendar)
            .set("calendarDisplayedMap", displayedCalendarMap).set("eventsDisplayedList", eventsDisplayedList)
            .set("tasksDisplayedList", tasksDisplayedList).set("date_act", dateLabel).ok()
            .withCharset(Tools.UTF_8);
}