Example usage for java.util Date toString

List of usage examples for java.util Date toString

Introduction

In this page you can find the example usage for java.util Date toString.

Prototype

public String toString() 

Source Link

Document

Converts this Date object to a String of the form:
 dow mon dd hh:mm:ss zzz yyyy
where:
  • dow is the day of the week ( Sun, Mon, Tue, Wed, Thu, Fri, Sat ).

    Usage

    From source file:org.jdesigner.platform.web.converter.DateTimeConverter.java

    /**
     * Convert an input Date/Calendar object into a String.
     * <p>/*w  ww .j  av a  2  s .co m*/
     * <b>N.B.</b>If the converter has been configured to with one or more
     * patterns (using <code>setPatterns()</code>), then the first pattern will
     * be used to format the date into a String. Otherwise the default
     * <code>DateFormat</code> for the default locale (and <i>style</i> if
     * configured) will be used.
     * 
     * @param value
     *            The input value to be converted
     * @return the converted String value.
     * @throws Throwable
     *             if an error occurs converting to a String
     */
    protected String convertToString(Object value) throws Throwable {
        Date date = null;
        if (value instanceof Date) {
            return DateUtils.dateToISO((Date) value);
        } else if (value instanceof Calendar) {
    
        } else if (value instanceof Calendar) {
            date = ((Calendar) value).getTime();
        } else if (value instanceof Long) {
            date = new Date(((Long) value).longValue());
        }
    
        if (date != null)
            return date.toString();
        String result = value.toString();
        return result;
    }
    

    From source file:fr.cls.atoll.motu.library.cas.util.AssertionUtils.java

    /**
     * Debug pgt.// w  w  w . ja va2s.com
     * 
     * @param assertion the assertion
     * 
     * @return the string
     */
    public static String debugPGT(Assertion assertion) {
        StringBuffer stringBuffer = new StringBuffer();
        if (assertion == null) {
            stringBuffer.append("\n Assertion is null \n");
            return stringBuffer.toString();
        }
    
        AttributePrincipal attributePrincipal = assertion.getPrincipal();
        if (attributePrincipal == null) {
            stringBuffer.append("\n AttributePrincipal is null \n");
            return stringBuffer.toString();
        }
    
        Date validFromDate = assertion.getValidFromDate();
        Date validUntilDate = assertion.getValidUntilDate();
    
        String principal = attributePrincipal.getName();
        stringBuffer.append("\n Principal: \n");
    
        if (principal == null) {
            stringBuffer.append("null");
        } else {
            stringBuffer.append(principal);
        }
    
        stringBuffer.append("\n Valid from: \n");
    
        if (validFromDate == null) {
            stringBuffer.append("null");
        } else {
            stringBuffer.append(validFromDate.toString());
        }
    
        stringBuffer.append("\n Valid until: \n");
    
        if (validUntilDate == null) {
            stringBuffer.append("null");
        } else {
            stringBuffer.append(validUntilDate.toString());
        }
    
        stringBuffer.append("\n Attributes: \n");
        Iterator<?> it = assertion.getAttributes().entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            stringBuffer.append("\n ");
            stringBuffer.append(entry.getKey());
            stringBuffer.append("=");
            stringBuffer.append(entry.getValue());
            stringBuffer.append(" \n");
        }
        return stringBuffer.toString();
    
    }
    

    From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java

    /**
     * Konkrete Ausprogrammierung der der Darstellung eines einzlenen Projekts
     * (Name, Anzahl Perioden mit Jahren, Aenderungsdatum, Loeschbutton). Diese
     * wird sowohl bei der ersten Erstellung des UIs fuer jedes Projekt
     * ausgefuehrt. Die Loeschbuttons werden einer Liste an Loeschbuttons
     * hinzufgefuegt umd spaeter eine identifikation der Buttons in der Methode
     * buttonClick zu gewaehrleisten. Zum Schluss wird dem Layout noch ein
     * Listener hinzugefuegt, der durch die Methode LayoutClick auf Klicks auf
     * ein jeweiliges Projekt reagiert und in die Prozesssicht des einzelnen
     * Projekts wechselt und das VerticalLayout dem projectListPanel
     * hinzgefuegt.//from   w  w w. ja  va  2s.com
     * 
     * @author Christian Scherer, Mirko Gpfrich
     * @param project
     *            das darzustellende Projekt und der aktuelle Index der Liste
     * @param i
     *            der Index der zu erstellenden Komponente (besonders fuer den
     *            Loeschbutton relevant)
     * @return ein VerticalLayout Objekt, das zur Eingliederung in das UI dient
     */
    private Panel generateSingleProjectUI(Project project, int i) {
    
        //erzeugt eine Panel fr ein Projekt
        singleProject = new Panel(project.getName());
        singleProject.setStyleName("borderless light projectlist");
    
        //Legt ein Layout fr das Projekt-Panel fest
        HorizontalLayout panelContent = new HorizontalLayout();
        //panelContent.setSizeFull();
        singleProject.setContent(panelContent);
        singleProject.setSizeFull();
        panelContent.addStyleName("projectListPanel");
    
        //Legt ein linkes und ein rechtes Layout innerhalb des Panels an.
        VerticalLayout panelContentLeft = new VerticalLayout();
        HorizontalLayout panelContentRight = new HorizontalLayout();
        panelContent.addComponent(panelContentLeft);
        panelContent.addComponent(panelContentRight);
        panelContent.setComponentAlignment(panelContentLeft, Alignment.BOTTOM_LEFT);
        panelContent.setComponentAlignment(panelContentRight, Alignment.BOTTOM_RIGHT);
        panelContentLeft.setWidth("340px");
    
        periodList = (NavigableSet<Period>) project.getPeriods();
    
        // String fuer saubere Periodenausgabe erstellen.
    
        String periodString;
        int numbersOfPeriods;
        numbersOfPeriods = project.getTotalPeriods();
    
        if (numbersOfPeriods == 0) {
            periodString = "Noch keine Perioden eingetragen";
        } else {
            periodString = "" + numbersOfPeriods + " Perioden";
        }
    
        String typMethod;
        typMethod = project.getTypMethod();
    
        projectTypAndPeriods = new Label(typMethod + ": " + periodString);
    
        // String fuer Ausgabe des letzten Aenderungsdatum
        String lastChangedString;
        if (project.getLastChanged() == null) {
            Date d = new Date();
            lastChangedString = "Zuletzt gendert: " + d.toString();
        } else {
            lastChangedString = "Zuletzt gendert: " + project.getLastChanged().toString();
        }
        lastChanged = new Label(lastChangedString);
    
        //Buttons erstellen
        final Button removeBtn = new Button("");
        final Button editBtn = new Button("");
    
        //Button formatieren
        removeBtn.addStyleName("borderless");
        removeBtn.setIcon(new ThemeResource("images/icons/trash.png"));
        editBtn.addStyleName("borderless");
        editBtn.setIcon(new ThemeResource("images/icons/pen.png"));
    
        //Button-Listener hinzufgen
        removeBtn.addListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;
    
            public void buttonClick(ClickEvent event) {
                final int index3 = removeBtnList.indexOf(event.getButton());
    
                logger.debug(
                        "Projekt-loeschen Button aus dem Hauptfenster aufgerufen. Projektnummer: " + (index3 + 1));
    
                ConfirmDialog.show(getWindow(), projects.get(index3).getName() + " lschen?",
                        "Wollen sie das Projekt wirklich lschen?", "Ja", "Nein", new ConfirmDialog.Listener() {
                            /**
                             * 
                             */
                            private static final long serialVersionUID = 1L;
    
                            @Override
                            public void onClose(ConfirmDialog dialog) {
                                if (dialog.isConfirmed()) {
                                    presenter.removeProject(projects.get(index3));
                                } else {
    
                                }
                            }
                        });
            }
        });
    
        editBtn.addListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;
    
            public void buttonClick(ClickEvent event) {
                indexEditBtn = editBtnList.indexOf(event.getButton());
    
                logger.debug("Projekt-bearbeiten Button aus dem Hauptfenster aufgerufen. Projektnummer: "
                        + (indexEditBtn + 1));
                presenter.editProjectDialog(projects.get(indexEditBtn));
            }
        });
    
        // Liste fr Buttons zur spaeteren Identifikation
        removeBtnList.add(removeBtn);
        editBtnList.add(editBtn);
        dialogEditBtnList.add(dialogEditBtn);
    
        //Inhalt dem Panel hinzufgen
        panelContentLeft.addComponent(projectTypAndPeriods);
        panelContentLeft.addComponent(lastChanged);
        panelContentRight.addComponent(removeBtnList.get(i));
        panelContentRight.addComponent(editBtnList.get(i));
    
        logger.debug("Edit-Button " + i + " hinzugefuegt");
    
        //CLick-Listener fr das Panel hinzufgen
        singleProject.addListener(this);
        projectListPanel.addComponent(singleProject);
        logger.debug("Einzelnes Projektelement erzeugt");
    
        return singleProject;
    }
    

    From source file:com.liteoc.bean.extract.odm.ClinicalDataReportBean.java

    protected void addOneDN(DiscrepancyNoteBean dn, String currentIndent) {
        StringBuffer xml = this.getXmlOutput();
        String indent = this.getIndent();
        String nls = System.getProperty("line.separator");
        //Boolean p = s.length()>0||i.length()>0||d.toString().length()>0||n>0 ? true : false;
        xml.append(currentIndent + "<OpenClinica:DiscrepancyNote ");
        if (dn.getOid() != null) {
            String i = dn.getOid();//from  w  w w  .  j av  a 2 s  .c o  m
            if (i.length() > 0) {
                xml.append("ID=\"" + StringEscapeUtils.escapeXml(i) + "\" ");
            }
        }
        if (dn.getStatus() != null) {
            String s = dn.getStatus();
            if (s.length() > 0) {
                xml.append("Status=\"" + s + "\" ");
            }
        }
        if (dn.getNoteType() != null) {
            String s = dn.getNoteType();
            if (s.length() > 0) {
                xml.append("NoteType=\"" + s + "\" ");
            }
        }
        if (dn.getDateUpdated() != null) {
            Date d = dn.getDateUpdated();
            if (d.toString().length() > 0) {
                xml.append("DateUpdated=\"" + new SimpleDateFormat("yyyy-MM-dd").format(d) + "\" ");
            }
        }
        int n = dn.getNumberOfChildNotes();
        if (n > 0) {
            xml.append("NumberOfChildNotes=\"" + dn.getNumberOfChildNotes() + "\"");
        }
        xml.append('>');
        xml.append(nls);
        if (dn.getChildNotes() != null && dn.getChildNotes().size() > 0) {
            for (ChildNoteBean cn : dn.getChildNotes()) {
                xml.append(currentIndent + indent + "<OpenClinica:ChildNote ");
                if (cn.getStatus() != null) {
                    String s = cn.getStatus();
                    if (s.length() > 0) {
                        xml.append("Status=\"" + s + "\" ");
                    }
                }
                if (cn.getDateCreated() != null) {
                    Date d = cn.getDateCreated();
                    if (d.toString().length() > 0) {
                        xml.append("DateCreated=\"" + new SimpleDateFormat("yyyy-MM-dd").format(d) + "\"");
                    }
                }
                xml.append('>');
                xml.append(nls);
                if (cn.getDescription() != null) {
                    String dc = cn.getDescription();
                    if (dc.length() > 0) {
                        xml.append(currentIndent + indent + indent + "<OpenClinica:Description>"
                                + StringEscapeUtils.escapeXml(dc) + "</OpenClinica:Description>");
                        xml.append(nls);
                    }
                }
                if (cn.getDetailedNote() != null) {
                    String nt = cn.getDetailedNote();
                    if (nt.length() > 0) {
                        xml.append(currentIndent + indent + indent + "<OpenClinica:DetailedNote>"
                                + StringEscapeUtils.escapeXml(nt) + "</OpenClinica:DetailedNote>");
                        xml.append(nls);
                    }
                }
                if (cn.getUserRef() != null) {
                    String uid = cn.getUserRef().getElementDefOID();
                    if (uid.length() > 0) {
                        xml.append(currentIndent + indent + indent + "<UserRef UserOID=\""
                                + StringEscapeUtils.escapeXml(uid) + "\"/>");
                        xml.append(nls);
                    }
                }
                xml.append(currentIndent + indent + "</OpenClinica:ChildNote>");
                xml.append(nls);
            }
        }
        xml.append(currentIndent + "</OpenClinica:DiscrepancyNote>");
        xml.append(nls);
    }
    

    From source file:com.liusoft.dlog4j.plugin.SearchEnginePlugIn.java

    /**
     * ?/*from  w w w . ja  v a2 s .c  o  m*/
     * 
     * @param pvdClass
     * @param time
     * @throws IOException
     */
    private void saveLastActiveTime(String pvdClass, Date time) throws IOException {
        StringBuffer status_file_uri = new StringBuffer(STATUS_FILE_PATH);
        status_file_uri.append(pvdClass);
        status_file_uri.append(".his");
        String realPath = context.getRealPath(status_file_uri.toString());
        Properties props = new Properties();
        FileOutputStream fos = null;
        try {
            props.setProperty(TIME_KEY, String.valueOf(time.getTime()));
            props.setProperty("LAST_TIME", time.toString());
            fos = new FileOutputStream(realPath);
            props.store(fos, null);
        } finally {
            props = null;
            if (fos != null) {
                fos.close();
                fos = null;
            }
        }
    }
    

    From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java

    public void loadBookmark() {
        if (bookmark != null) {
    
            if (isMyself() && bookmark.getId() != 0) {
                try {
                    int id = bookmark.getId();
                    bookmark = BookmarkManager.GetById(id, base);
                } catch (ContentNotFoundException e) {
                }/*  w w w. java 2  s .c om*/
            }
    
            if (viewType == BookmarkViewType.VIEW) {
                mBookmarkView.setVisibility(View.VISIBLE);
                readSection.setVisibility(View.GONE);
                mWebContent.setVisibility(View.GONE);
                if (isMyself()) {
                    Date d = new Date(bookmark.getTime());
    
                    mTitle.setText(bookmark.getDescription());
                    mUrl.setText(bookmark.getUrl());
                    mNotes.setText(bookmark.getNotes());
                    mTime.setText(d.toString());
                    mUsername.setText(bookmark.getAccount());
    
                    if (mIcon != null) {
                        if (!bookmark.getShared()) {
                            mIcon.setImageResource(R.drawable.padlock);
                        }
                    }
    
                    SpannableStringBuilder tagBuilder = new SpannableStringBuilder();
    
                    for (Tag t : bookmark.getTags()) {
                        addTag(tagBuilder, t, tagOnClickListener);
                    }
    
                    mTags.setText(tagBuilder);
                    mTags.setMovementMethod(LinkMovementMethod.getInstance());
                } else {
    
                    Date d = new Date(bookmark.getTime());
    
                    if (bookmark.getDescription() != null && !bookmark.getDescription().equals("null"))
                        mTitle.setText(bookmark.getDescription());
    
                    mUrl.setText(bookmark.getUrl());
    
                    if (bookmark.getNotes() != null && !bookmark.getNotes().equals("null"))
                        mNotes.setText(bookmark.getNotes());
    
                    mTime.setText(d.toString());
    
                    SpannableStringBuilder tagBuilder = new SpannableStringBuilder();
    
                    for (Tag t : bookmark.getTags()) {
                        addTag(tagBuilder, t, userTagOnClickListener);
                    }
    
                    mTags.setText(tagBuilder);
                    mTags.setMovementMethod(LinkMovementMethod.getInstance());
    
                    if (bookmark.getAccount() != null) {
                        SpannableStringBuilder builder = new SpannableStringBuilder();
                        int start = builder.length();
                        builder.append(bookmark.getAccount());
                        int end = builder.length();
    
                        AccountSpan span = new AccountSpan(bookmark.getAccount());
                        span.setOnAccountClickListener(accountOnClickListener);
    
                        builder.setSpan(span, start, end, 0);
    
                        mUsername.setText(builder);
                    }
    
                    mUsername.setMovementMethod(LinkMovementMethod.getInstance());
                }
            } else if (viewType == BookmarkViewType.READ) {
                new GetArticleTask().execute(bookmark.getUrl());
            } else if (viewType == BookmarkViewType.WEB) {
                showInWebView();
            }
        }
    }
    

    From source file:org.etudes.jforum.view.forum.common.TopicsCommon.java

    public static List prepareDiffTopics(List topics) throws Exception {
        UserSession userSession = SessionFacade.getUserSession();
    
        long lastVisit = userSession.getLastVisit().getTime();
        // int hotBegin = SystemGlobals.getIntValue(ConfigKeys.HOT_TOPIC_BEGIN);
        int hotBegin = SakaiSystemGlobals.getIntValue(ConfigKeys.HOT_TOPIC_BEGIN);
    
        // int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE);
        int postsPerPage = SakaiSystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE);
        Map topicsTracking = (HashMap) SessionFacade.getAttribute(ConfigKeys.TOPICS_TRACKING);
        List newTopics = new ArrayList(topics.size());
    
        boolean checkUnread = (userSession.getUserId() != SystemGlobals.getIntValue(ConfigKeys.ANONYMOUS_USER_ID));
    
        List topicMarkTimes = null;//from ww  w . j  ava  2  s .  c o  m
        if (topics.size() > 0) {
            topicMarkTimes = DataAccessDriver.getInstance().newTopicMarkTimeDAO()
                    .selectCourseTopicMarkTimes(userSession.getUserId());
        }
    
        Date markAllDate = null;
    
        markAllDate = userSession.getMarkAllTime();
        if (markAllDate == null) {
            //First date mentioned in Java API
            GregorianCalendar gc = new GregorianCalendar(1970, 0, 1);
            markAllDate = gc.getTime();
        }
        /*Date lastVisitDate = userSession.getLastVisit();
                
        Date compareDate;
        if (markAllDate == null)
        {
          System.out.println("LastVisit setting to false,markDate is null ");
          compareDate = lastVisitDate;
        }
        else
        {
          if (lastVisitDate.getTime() > markAllDate.getTime())
          {
        System.out.println("LastVisit setting to false ");
        compareDate = lastVisitDate;
          }
          else
          {
        System.out.println("markAll setting to false ");   
        compareDate = markAllDate;
          }
        }*/
        TopicMarkTimeDAO tmark = DataAccessDriver.getInstance().newTopicMarkTimeDAO();
    
        for (Iterator iter = topics.iterator(); iter.hasNext();) {
            boolean read = false;
            Topic t = (Topic) iter.next();
    
            Date markTime = null;
            Date compareDate = null;
    
            //markTime = tmark.selectMarkTime(t.getId(), SessionFacade.getUserSession().getUserId());
    
            for (Iterator mIter = topicMarkTimes.iterator(); mIter.hasNext();) {
                TopicMarkTimeObj tmObj = (TopicMarkTimeObj) mIter.next();
                if (tmObj.getTopicId() == t.getId()) {
                    markTime = tmObj.getMarkTime();
                    break;
                }
    
            }
            if (markTime == null) {
                GregorianCalendar gc = new GregorianCalendar(1970, 0, 1);
                markTime = gc.getTime();
            }
    
            if (markAllDate.getTime() > markTime.getTime()) {
                compareDate = markAllDate;
            } else {
                compareDate = markTime;
            }
            System.out.println("For topic id " + t.getId() + " compareDate is " + compareDate.toString());
            //Mallika - changing line below from lastVisit to compareDate.getTime()         
            if (checkUnread && t.getLastPostTimeInMillis().getTime() > compareDate.getTime()) {
                if (topicsTracking.containsKey(new Integer(t.getId()))) {
                    read = (t.getLastPostTimeInMillis()
                            .getTime() == ((Long) topicsTracking.get(new Integer(t.getId()))).longValue());
                }
            } else {
                read = true;
            }
    
            if (t.getTotalReplies() + 1 > postsPerPage) {
                t.setPaginate(true);
                t.setTotalPages(new Double(Math.floor(t.getTotalReplies() / postsPerPage)));
            } else {
                t.setPaginate(false);
                t.setTotalPages(new Double(0));
            }
    
            // Check if this is a hot topic
            t.setHot(t.getTotalReplies() >= hotBegin);
    
            t.setRead(read);
            newTopics.add(t);
        }
    
        return newTopics;
    }
    

    From source file:org.alfresco.repo.activities.feed.cleanup.FeedCleaner.java

    /**
     * Does the actual cleanup, expecting the lock to be maintained
     * /* w  ww . j a  v  a 2s .  c o m*/
     * @param keepGoing <tt>true</tt> to continue but will switch to <tt>false</tt> to stop
     * @return          number of entries deleted through whatever means
     */
    private int executeWithLock(final AtomicBoolean keepGoing) throws JobExecutionException {
        int maxIdRangeDeletedCount = 0;
        int maxAgeDeletedCount = 0;
        int maxSizeDeletedCount = 0;
    
        try {
            /*
             * ALF-15383 (DH 15/08/2012)
             * Previously, we allowed maxFeedSize entries per user per site per format.
             * This scaled badly because some users (especially under test conditions)
             * were able to perform actions across many thousands of sites.  If the size
             * limit was 100 and the user belonged to 50K sites, we allowed 5M feed entries
             * for that user.  This may have been OK but for the fact that the queries
             * doing the work are not covered by appropriate indexes to support the where
             * and sort by clauses.
             * In fact, give the current state of indexes, it is necessary to limit the absolute
             * number of feed entries.  We can't use count() queries (they are poor) and cannot
             * reasonably sort by date and trim by count.  Therefore I have introduced an
             * absolute ID range trim that runs before everything else.
             */
    
            if (maxIdRange > 0 && keepGoing.get()) {
                maxIdRangeDeletedCount = feedDAO.deleteFeedEntries(maxIdRange);
                if (logger.isTraceEnabled()) {
                    logger.trace("Cleaned " + maxIdRangeDeletedCount + " entries to keep ID range of " + maxIdRange
                            + ".");
                }
            }
    
            if (maxAgeMins > 0 && keepGoing.get()) {
                // clean old entries based on maxAgeMins
    
                long nowTimeOffset = new Date().getTime();
                long keepTimeOffset = nowTimeOffset - ((long) maxAgeMins * 60000L); // millsecs = mins * 60 secs * 1000 msecs
                Date keepDate = new Date(keepTimeOffset);
    
                maxAgeDeletedCount = feedDAO.deleteFeedEntries(keepDate);
                if (logger.isTraceEnabled()) {
                    logger.trace("Cleaned " + maxAgeDeletedCount + " entries (upto " + keepDate + ", max age "
                            + maxAgeMins + " mins)");
                }
            }
    
            // TODO:    ALF-15511
            if (maxFeedSize > 0 && keepGoing.get()) {
                // Get user+format feeds exceeding the required maximum
                if (logger.isTraceEnabled()) {
                    logger.trace("Selecting user+format feeds exceeding the required maximum of " + maxFeedSize
                            + " entries.");
                }
                List<ActivityFeedEntity> userFeedsTooMany = feedDAO.selectUserFeedsToClean(maxFeedSize);
                for (ActivityFeedEntity userFeedTooMany : userFeedsTooMany) {
                    if (!keepGoing.get()) {
                        if (logger.isTraceEnabled()) {
                            logger.trace("Stopping cleaning the feeds.");
                        }
                        break;
                    }
                    if (logger.isTraceEnabled()) {
                        logger.trace("Found user activity feed entity: " + userFeedTooMany.toString());
                    }
                    String feedUserId = userFeedTooMany.getFeedUserId();
                    // Rather than filter out the two usernames that indicate site-specific
                    // feed entries, we can just filter them out now.
                    if (ActivitiesDAO.KEY_ACTIVITY_NULL_VALUE.equals(feedUserId)) {
                        if (logger.isTraceEnabled()) {
                            logger.trace("Found site-specific feed entries, filtering.");
                        }
                        continue;
                    }
                    // Get the feeds to keep
                    if (logger.isTraceEnabled()) {
                        logger.trace("Get the feeds to keep for user for all sites, not exluding users.");
                    }
                    List<ActivityFeedEntity> feedsToKeep = feedDAO.selectUserFeedEntries(feedUserId, null, false,
                            false, -1L, maxFeedSize);
                    if (logger.isTraceEnabled()) {
                        for (ActivityFeedEntity feedToKeep : feedsToKeep) {
                            logger.trace("Found user activity feed entity to keep: " + feedToKeep.toString());
                        }
                    }
                    // If the feeds have been removed, then ignore
                    if (feedsToKeep.size() < maxFeedSize) {
                        if (logger.isTraceEnabled()) {
                            logger.trace("Found less then " + maxFeedSize + " .The feeds were removed, ignoring.");
                        }
                        continue;
                    }
                    // Get the last one
                    Date oldestFeedEntry = feedsToKeep.get(maxFeedSize - 1).getPostDate();
    
                    if (logger.isTraceEnabled()) {
                        logger.trace("Deleting the oldest feed entry: " + oldestFeedEntry.toString());
                    }
                    int deletedCount = feedDAO.deleteUserFeedEntries(feedUserId, oldestFeedEntry);
                    if (logger.isTraceEnabled()) {
                        logger.trace("Cleaned " + deletedCount + " entries for user '" + feedUserId + "'.");
                    }
                    maxSizeDeletedCount += deletedCount;
                }
    
                // Get site+format feeds exceeding the required maximum
                if (logger.isTraceEnabled()) {
                    logger.trace("Selecting site+format feeds exceeding the required maximum of " + maxFeedSize
                            + " entries.");
                }
                List<ActivityFeedEntity> siteFeedsTooMany = feedDAO.selectSiteFeedsToClean(maxFeedSize);
                for (ActivityFeedEntity siteFeedTooMany : siteFeedsTooMany) {
                    if (!keepGoing.get()) {
                        if (logger.isTraceEnabled()) {
                            logger.trace("Stopping cleaning the feeds.");
                        }
                        break;
                    }
                    if (logger.isTraceEnabled()) {
                        logger.trace("Found site activity feed entity: " + siteFeedTooMany.toString());
                    }
                    String siteId = siteFeedTooMany.getSiteNetwork();
                    // Get the feeds to keep
                    if (logger.isTraceEnabled()) {
                        logger.trace("Get the feeds to keep for site.");
                    }
                    List<ActivityFeedEntity> feedsToKeep = feedDAO.selectSiteFeedEntries(siteId, maxFeedSize);
                    if (logger.isTraceEnabled()) {
                        for (ActivityFeedEntity feedToKeep : feedsToKeep) {
                            logger.trace("Found site activity feed entity to keep: " + feedToKeep.toString());
                        }
                    }
                    // If the feeds have been removed, then ignore
                    if (feedsToKeep.size() < maxFeedSize) {
                        continue;
                    }
                    // Get the last one
                    Date oldestFeedEntry = feedsToKeep.get(maxFeedSize - 1).getPostDate();
                    if (logger.isTraceEnabled()) {
                        logger.trace("Deleting the oldest feed entry: " + oldestFeedEntry.toString());
                    }
                    int deletedCount = feedDAO.deleteSiteFeedEntries(siteId, oldestFeedEntry);
                    if (logger.isTraceEnabled()) {
                        logger.trace("Cleaned " + deletedCount + " entries for site '" + siteId + "'.");
                    }
                    maxSizeDeletedCount += deletedCount;
                }
            }
        } catch (SQLException e) {
            logger.error("Exception during cleanup of feeds", e);
            throw new JobExecutionException(e);
        } catch (Throwable e) {
            // We were told to stop, which is also what will happen if the VM shuts down
            if (!keepGoing.get()) {
                // Ignore
            } else {
                logger.error("Exception during cleanup of feeds", e);
            }
        }
    
        return (maxIdRangeDeletedCount + maxAgeDeletedCount + maxSizeDeletedCount);
    }
    

    From source file:de.crowdcode.kissmda.cartridges.simplejava.InterfaceGenerator.java

    /**
     * Generate the Java package from UML package.
     * /*from   www  . j  a v  a 2s.  c o m*/
     * @param clazz
     *            the UML class
     * @param ast
     *            the JDT Java AST
     * @param cu
     *            the generated Java compilation unit
     */
    public void generatePackage(Classifier clazz, AST ast, CompilationUnit cu) {
        PackageDeclaration pd = ast.newPackageDeclaration();
        String fullPackageName = getFullPackageName(clazz);
        pd.setName(ast.newName(fullPackageName));
    
        Date now = new Date();
        String commentDate = "Generation date: " + now.toString() + ".";
    
        generatePackageJavadoc(ast, pd, PackageComment.CONTENT_1.getValue(), PackageComment.CONTENT_2.getValue(),
                " ", PackageComment.CONTENT_3.getValue(), " ", commentDate);
    
        cu.setPackage(pd);
    }