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:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeNoTime.java

    public boolean snapshotCreation(AmazonEC2Client ec2Client, Volume vol, String period, Date date) {
        if ((date == null) || (ec2Client == null) || (vol == null) || (period == null)) {
            return false;
        }/*from  ww  w .ja  va 2  s . c  om*/
    
        try {
    
            if ("day".equalsIgnoreCase(period)) {
            } else if ("hour".equalsIgnoreCase(period)) {
            } else if ("week".equalsIgnoreCase(period)) {
            } else if ("month".equalsIgnoreCase(period)) {
            } else {
                logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId()
                        + "\"");
                return false;
            }
    
            Collection<Tag> tags_volume = getResourceTags(vol);
    
            String volumeAttachmentInstance = "none";
            try {
                volumeAttachmentInstance = vol.getAttachments().get(0).getInstanceId();
            } catch (Exception e) {
                logger.debug("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Volume not attached to instance: " + vol.getVolumeId());
            }
    
            String description = period + "_snapshot " + vol.getVolumeId() + " by Eidetic at " + date.toString()
                    + ". Volume attached to " + volumeAttachmentInstance;
    
            Snapshot current_snap;
            try {
                current_snap = createSnapshotOfVolume(ec2Client, vol, description, numRetries_,
                        maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_);
            } catch (Exception e) {
                logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=\"Error\", Error=\"error creating snapshot from volume\", Volume_id=\""
                        + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                return false;
            }
    
            try {
                setResourceTags(ec2Client, current_snap, tags_volume, numRetries_, maxApiRequestsPerSecond_,
                        uniqueAwsAccountIdentifier_);
            } catch (Exception e) {
                logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event\"Error\", Error=\"error adding tags to snapshot\", Snapshot_id=\""
                        + current_snap.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                return false;
            }
    
        } catch (Exception e) {
            logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                    + "\",Event=\"Error, Error=\"error in snapshotCreation\", stacktrace=\"" + e.toString()
                    + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\"");
            return false;
        }
    
        return true;
    }
    

    From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotChecker.java

    public boolean snapshotCreation(AmazonEC2Client ec2Client, Volume vol, String period, Date date) {
        if ((date == null) || (ec2Client == null) || (vol == null) || (period == null)) {
            return false;
        }//from www. ja  va2 s  .c o  m
    
        try {
    
            if ("day".equalsIgnoreCase(period)) {
            } else if ("hour".equalsIgnoreCase(period)) {
            } else if ("week".equalsIgnoreCase(period)) {
            } else if ("month".equalsIgnoreCase(period)) {
            } else {
                logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId()
                        + "\"");
                return false;
            }
    
            Collection<Tag> tags_volume = getResourceTags(vol);
    
            String volumeAttachmentInstance = "none";
            try {
                volumeAttachmentInstance = vol.getAttachments().get(0).getInstanceId();
            } catch (Exception e) {
                logger.debug("Volume not attached to instance: " + vol.getVolumeId());
            }
    
            String description = period + "_snapshot " + vol.getVolumeId() + " by snapshot checker at "
                    + date.toString() + ". Volume attached to " + volumeAttachmentInstance;
    
            Snapshot current_snap;
            try {
                current_snap = createSnapshotOfVolume(ec2Client, vol, description, numRetries_,
                        maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_);
            } catch (Exception e) {
                logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=\"Error\", Error=\"error creating snapshot from volume\", Volume_id=\""
                        + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                return false;
            }
    
            try {
                setResourceTags(ec2Client, current_snap, tags_volume, numRetries_, maxApiRequestsPerSecond_,
                        uniqueAwsAccountIdentifier_);
            } catch (Exception e) {
                logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=\"Error\", Error=\"error adding tags to snapshot\", Snapshot_id=\""
                        + current_snap.getSnapshotId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                return false;
            }
    
        } catch (Exception e) {
            logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_
                    + "\",Event=\"Error\", Error=\"error in snapshotCreation\", stacktrace=\"" + e.toString()
                    + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\"");
            return false;
        }
    
        return true;
    }
    

    From source file:de.cismet.cids.custom.utils.berechtigungspruefung.BerechtigungspruefungHandler.java

    /**
     * DOCUMENT ME!//from   www .  j  av  a  2  s.com
     *
     * @param  user  DOCUMENT ME!
     */
    public void deleteOldDateianhangFiles(final User user) {
        final File directory = new File(BerechtigungspruefungProperties.getInstance().getAnhangAbsPath());
        final Date thresholdDate = getThresholdAnhangDate();
    
        // look for all anhang files
        for (final File file : directory.listFiles()) {
            if (file.isFile()) {
                try {
                    final String fileName = file.getName();
                    final BasicFileAttributes attr = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
                    final Date creationDate = new Date(attr.creationTime().toMillis());
    
                    // file older then threshold date (1 month) ?
                    if (creationDate.before(thresholdDate)) {
                        final CidsBean anfrageBean = loadAnfrageBean(user, fileName);
                        // assuring, that the file corresponds to an existing bean This prevents accidental deletion of
                        // non-anhang files (i.e. if AnhangAbsPath was set to a path that contains also other files)
                        if (anfrageBean != null) {
                            final Timestamp anfrageTs = (Timestamp) anfrageBean.getProperty("anfrage_timestamp");
                            // timestamp filed in the bean agrees with the file creation date ?
                            if (anfrageTs.before(thresholdDate)) {
                                LOG.info("deleting old Anhang file: " + file.getName() + " (date: "
                                        + creationDate.toString() + ")");
                                // now we can delete (hopefully)
                                file.delete();
                            }
                        }
                    }
                } catch (final IOException ex) {
                    LOG.warn("could not delete Anhang file: " + file.getName(), ex);
                }
            }
        }
    }
    

    From source file:fr.gouv.culture.vitam.eml.PstExtract.java

    private Element extractInfoTask(PSTTask task) {
        Element root = XmlDom.factory.createElement("task");
    
        String value = null;//from   ww  w  .j a v  a2s.  c  o m
    
        Integer ival = task.getTaskStatus();
        root.add(XmlDom.factory.createElement("TaskStatus").addText(ival.toString()));
        Double dval = task.getPercentComplete();
        root.add(XmlDom.factory.createElement("PercentComplete").addText(dval.toString()));
        Boolean bval = task.isTeamTask();
        root.add(XmlDom.factory.createElement("isTeamTask").addText(bval.toString()));
        Date date = task.getTaskStartDate();
        if (date != null) {
            root.add(XmlDom.factory.createElement("TaskStartDate").addText(date.toString()));
        }
        date = task.getTaskDueDate();
        if (date != null) {
            root.add(XmlDom.factory.createElement("TaskDueDate").addText(date.toString()));
        }
        date = task.getTaskDateCompleted();
        if (date != null) {
            root.add(XmlDom.factory.createElement("TaskDateCompleted").addText(date.toString()));
        }
        ival = task.getTaskActualEffort();
        root.add(XmlDom.factory.createElement("TaskActualEffort").addText(ival.toString()));
        ival = task.getTaskEstimatedEffort();
        root.add(XmlDom.factory.createElement("TaskEstimatedEffort").addText(ival.toString()));
        ival = task.getTaskVersion();
        root.add(XmlDom.factory.createElement("TaskVersion").addText(ival.toString()));
        bval = task.isTaskComplete();
        root.add(XmlDom.factory.createElement("isTaskComplete").addText(bval.toString()));
        value = task.getTaskOwner();
        if (value != null && !value.isEmpty()) {
            root.add(XmlDom.factory.createElement("TaskOwner").addText(value));
        }
        value = task.getTaskAssigner();
        if (value != null && !value.isEmpty()) {
            root.add(XmlDom.factory.createElement("TaskAssigner").addText(value));
        }
        value = task.getTaskLastUser();
        if (value != null && !value.isEmpty()) {
            root.add(XmlDom.factory.createElement("TaskLastUser").addText(value));
        }
        ival = task.getTaskOrdinal();
        root.add(XmlDom.factory.createElement("TaskOrdinal").addText(ival.toString()));
        bval = task.isTaskFRecurring();
        root.add(XmlDom.factory.createElement("isTaskFRecurring").addText(bval.toString()));
        value = task.getTaskRole();
        if (value != null && !value.isEmpty()) {
            root.add(XmlDom.factory.createElement("TaskRole").addText(value));
        }
        ival = task.getTaskOwnership();
        root.add(XmlDom.factory.createElement("TaskOwnership").addText(ival.toString()));
        ival = task.getAcceptanceState();
        root.add(XmlDom.factory.createElement("AcceptanceState").addText(ival.toString()));
        return root;
    }
    

    From source file:org.linagora.linshare.core.service.impl.UploadRequestServiceImpl.java

    /**
     * Check if the current input date is after now and not before now more the
     * functionality duration if delegation policy allowed it.
     * now() < currentDate <  now() + func.value
     * Otherwise functionality value is used as default value.
     * @param func/*from  w  w w.j a  v  a2s .  c om*/
     * @param currentDate
     * @param expirationDate TODO
     * @return the proper date is returned according to activation policy,
     * configuration policy and others checks.
     */
    private Date checkNotificationDate(TimeUnitValueFunctionality func, Date currentDate, Date expirationDate) {
        if (func.getActivationPolicy().getStatus()) {
            logger.debug(func.getIdentifier() + " is activated");
            Calendar c = new GregorianCalendar();
            c.setTime(expirationDate);
            c.add(func.toCalendarValue(), -func.getValue());
            Date minDate = c.getTime();
            if (func.getDelegationPolicy() != null && func.getDelegationPolicy().getStatus()) {
                logger.debug(func.getIdentifier() + " has a delegation policy");
                if (currentDate != null) {
                    if (!(currentDate.before(expirationDate) && currentDate.after(minDate))) {
                        //   if (!(currentDate.after(new Date()) && currentDate.before(maxDate))) {
                        logger.warn("the current value " + currentDate.toString() + " is out of range : "
                                + func.toString());
                        return minDate;
                    }
                    return currentDate;
                } else {
                    return minDate;
                }
            } else {
                // there is no delegation, the current value should be the
                // system value or null
                logger.debug(func.getIdentifier() + " does not have a delegation policy");
                if (currentDate != null) {
                    if (!currentDate.equals(minDate)) {
                        logger.warn("the current value " + currentDate.toString()
                                + " is different than system value " + minDate);
                    }
                }
                return minDate;
            }
        } else {
            logger.debug(func.getIdentifier() + " is not activated");
            if (currentDate != null) {
                logger.warn("the current value " + currentDate.toString() + " should be null for the functionality "
                        + func.toString());
            }
            return null;
        }
    }
    

    From source file:ome.formats.importer.gui.HistoryDB.java

    public DefaultListModel getBaseTableDataByDate(Date start, Date end) {
        ResultSet rs;/*from   ww w  .ja  v  a  2  s. co  m*/
        try {
            rs = getQueryResults("SELECT * FROM import_table" + " WHERE date BETWEEN '" + sqlDateFormat.format(end)
                    + "' AND '" + sqlDateFormat.format(start) + "'");
    
            String icon;
            DefaultListModel list = new DefaultListModel();
            for (; rs.next();) {
                if (rs.getString("status").equals("complete"))
                    icon = "gfx/import_done_16.png";
                else
                    icon = "gfx/warning_msg16.png";
                String dayString = day.format(rs.getObject("date"));
                String hourString = hour.format(rs.getObject("date"));
    
                if (day.format(new Date()).equals(dayString))
                    dayString = "Today";
    
                if (day.format(getYesterday()).equals(dayString)) {
                    dayString = "Yesterday";
                }
    
                ImportEntry entry = new ImportEntry(dayString + " " + hourString, icon, rs.getInt("uID"));
                list.addElement(entry);
            }
            return list;
        } catch (SQLException e) {
            String s = String.format("Error retrieving import list from %s to %s.", start.toString(),
                    end.toString());
            log.error(s, e);
        }
        return null;
    }
    

    From source file:org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditServiceImpl.java

    /**
     * Writes the start of the audit trail stream to the given writer
     *
     * @param writer The writer to write to/*from   w w w. ja v  a2s. c  om*/
     * @params params The parameters being used
     * @param reportFormat The format to write the header in
     * @throws IOException
     */
    private void writeAuditTrailHeader(Writer writer, RecordsManagementAuditQueryParameters params,
            ReportFormat reportFormat) throws IOException {
        if (writer == null) {
            return;
        }
    
        if (reportFormat == ReportFormat.HTML) {
            // write header as HTML
            writer.write(
                    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
            writer.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n");
            writer.write("<title>");
            writer.write(I18NUtil.getMessage(MSG_AUDIT_REPORT));
            writer.write("</title></head>\n");
            writer.write("<style>\n");
            writer.write("body { font-family: arial,verdana; font-size: 81%; color: #333; }\n");
            writer.write(".label { margin-right: 5px; font-weight: bold; }\n");
            writer.write(".value { margin-right: 40px; }\n");
            writer.write(".audit-info { background-color: #efefef; padding: 10px; margin-bottom: 4px; }\n");
            writer.write(".audit-entry { border: 1px solid #bbb; margin-top: 15px; }\n");
            writer.write(".audit-entry-header { background-color: #bbb; padding: 8px; }\n");
            writer.write(".audit-entry-node { padding: 10px; }\n");
            writer.write(".changed-values-table { margin-left: 6px; margin-bottom: 2px;width: 99%; }\n");
            writer.write(".changed-values-table th { text-align: left; background-color: #eee; padding: 4px; }\n");
            writer.write(".changed-values-table td { width: 33%; padding: 4px; border-top: 1px solid #eee; }\n");
            writer.write("</style>\n");
            writer.write("<body>\n<h2>");
            writer.write(I18NUtil.getMessage(MSG_AUDIT_REPORT));
            writer.write("</h2>\n");
            writer.write("<div class=\"audit-info\">\n");
    
            writer.write("<span class=\"label\">From:</span>");
            writer.write("<span class=\"value\">");
            Date from = params.getDateFrom();
            writer.write(from == null ? "&lt;Not Set&gt;" : StringEscapeUtils.escapeHtml(from.toString()));
            writer.write("</span>");
    
            writer.write("<span class=\"label\">To:</span>");
            writer.write("<span class=\"value\">");
            Date to = params.getDateTo();
            writer.write(to == null ? "&lt;Not Set&gt;" : StringEscapeUtils.escapeHtml(to.toString()));
            writer.write("</span>");
    
            writer.write("<span class=\"label\">Property:</span>");
            writer.write("<span class=\"value\">");
            QName prop = params.getProperty();
            writer.write(prop == null ? "All" : StringEscapeUtils.escapeHtml(getPropertyLabel(prop)));
            writer.write("</span>");
    
            writer.write("<span class=\"label\">User:</span>");
            writer.write("<span class=\"value\">");
            writer.write(params.getUser() == null ? "All" : StringEscapeUtils.escapeHtml(params.getUser()));
            writer.write("</span>");
    
            writer.write("<span class=\"label\">Event:</span>");
            writer.write("<span class=\"value\">");
            writer.write(params.getEvent() == null ? "All"
                    : StringEscapeUtils.escapeHtml(getAuditEventLabel(params.getEvent())));
            writer.write("</span>\n");
    
            writer.write("</div>\n");
        } else {
            // write header as JSON
            writer.write("{\n\t\"data\":\n\t{");
            writer.write("\n\t\t\"started\": \"");
            writer.write(ISO8601DateFormat.format(getStartOfDay(params.getDateFrom())));
            writer.write("\",\n\t\t\"stopped\": \"");
            writer.write(ISO8601DateFormat.format(getEndOfDay(params.getDateTo())));
            writer.write("\",\n\t\t\"enabled\": ");
            writer.write(Boolean.toString(isEnabled()));
            writer.write(",\n\t\t\"entries\":[");
        }
    }
    

    From source file:org.kuali.kfs.module.endow.batch.service.impl.GeneralLedgerInterfaceBatchProcessServiceImpl.java

    /**
     * method to get transaction description
     * @param transactionArchive// w w  w .  j av  a 2s.c  om
     * @return transaction description
     */
    protected String getTransactionDescription(GlInterfaceBatchProcessKemLine transactionArchive,
            java.util.Date postedDate) {
        String actityType = null;
    
        if (transactionArchive.getSubTypeCode().equalsIgnoreCase(EndowConstants.TransactionSubTypeCode.CASH)) {
            actityType = EndowConstants.KemToGLInterfaceBatchProcess.SUB_TYPE_CASH;
        } else {
            actityType = EndowConstants.KemToGLInterfaceBatchProcess.SUB_TYPE_NON_CASH;
        }
    
        return ("Net " + transactionArchive.getTypeCode() + " " + actityType + " Activity on "
                + postedDate.toString());
    }
    

    From source file:com.couchbase.client.ViewTest.java

    /**
     * This test case adds two non-JSON documents and
     * utilises a special view that returns them.
     *
     * @pre Create non-JSON documents and set them to the db.
     * Prepare a view query with docs and iterate over the response.
     * Find the non json documents in the result set and assert them.
     * @post This makes sure that the view handlers don't break when
     * non-JSON data is read from the view.//from w  w  w  .  j  ava  2 s . co  m
     */
    @Test
    public void testViewWithBinaryDocs() {
        // Create non-JSON documents
        Date now = new Date();
        client.set("nonjson1", 0, now);
        client.set("nonjson2", 0, 42);
    
        View view = client.getView(DESIGN_DOC_BINARY, VIEW_NAME_BINARY);
        Query query = new Query();
        query.setIncludeDocs(true);
        query.setReduce(false);
        query.setStale(Stale.FALSE);
    
        assert view != null : "Could not retrieve view";
        ViewResponse response = client.query(view, query);
    
        Iterator<ViewRow> itr = response.iterator();
        while (itr.hasNext()) {
            ViewRow row = itr.next();
            if (row.getKey().equals("nonjson1")) {
                assertEquals(now.toString(), row.getDocument().toString());
            }
            if (row.getKey().equals("nonjson2")) {
                assertEquals(42, row.getDocument());
            }
        }
    }
    

    From source file:org.etudes.mneme.impl.AssessmentStorageSql.java

    /**
     * {@inheritDoc}//  w  w w. ja  v  a  2 s . c o m
     */
    public List<String> clearStaleMintAssessments(final Date stale) {
        final List<String> rv = new ArrayList<String>();
    
        this.sqlService.transact(new Runnable() {
            public void run() {
                clearStaleMintQuestionsTx(stale, rv);
            }
        }, "clearStaleMintQuestions: " + stale.toString());
    
        return rv;
    }