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.esri.geoevent.solutions.processor.updateOnly.UpdateOnlyProcessor.java

    @Override
    public GeoEvent process(GeoEvent geoEvent) throws Exception {
        String trackID = geoEvent.getTrackId();
        Date startTime = geoEvent.getStartTime();
        if (trackCache.containsKey(trackID)) {
            Date lastTime = trackCache.get(trackID);
            // Filter out any tracks that haven't been updated since last time
            if (!startTime.after(lastTime)) {
                LOG.trace("UpdateOnlyProcessor ignoring track as nothing new since last time: " + trackID + " : "
                        + startTime.toString());
                return null;
            }// w w  w .jav a  2  s  . c o m
            LOG.trace("UpdateOnlyProcessor is handling new data for track " + trackID + " : " + startTime.toString()
                    + " is more recent than " + lastTime.toString());
        } else {
            LOG.trace("UpdateOnlyProcessor is handling a new track: " + trackID + " : " + startTime.toString());
        }
        // If we've reached here, then either there's an update to a track in the cache, or there's a new track, so record it in the cache
        trackCache.put(trackID, startTime);
        //... and allow the geoEvent through
        return geoEvent;
    }
    

    From source file:bbct.android.common.activity.MainActivity.java

    private void showSurvey2Dialog() {
        DateFormat dateFormat = DateFormat.getDateInstance();
        Date today = new Date();
        final String todayStr = dateFormat.format(today);
    
        if (prefs.contains(SharedPreferenceKeys.SURVEY1_DATE)
                && !prefs.contains(SharedPreferenceKeys.SURVEY2_DATE)) {
            String survey1Date = prefs.getString(SharedPreferenceKeys.SURVEY1_DATE, today.toString());
    
            try {/*from  w ww . ja v a 2 s  .  c  o m*/
                Calendar cal = Calendar.getInstance();
                cal.setTime(dateFormat.parse(survey1Date));
                cal.add(Calendar.DATE, SURVEY_DELAY);
                if (today.after(cal.getTime())) {
                    DialogUtil.showSurveyDialog(this, todayStr, R.string.survey2, SharedPreferenceKeys.SURVEY2_DATE,
                            SURVEY2_URI);
                }
            } catch (ParseException e) {
                Log.d(TAG, "Error parsing install date");
                e.printStackTrace();
            }
        } else if (prefs.contains(SharedPreferenceKeys.SURVEY_TAKEN_PREF)) {
            prefs.edit().putString(SharedPreferenceKeys.SURVEY1_DATE, todayStr).apply();
        }
    }
    

    From source file:org.exoplatform.cms.common.CommonUtils.java

    static public File getXMLFile(ByteArrayOutputStream bos, String appName, String objectType, Date createDate,
            String fileName) throws Exception {
        byte[] byteData = bos.toByteArray();
    
        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputStream is = new ByteArrayInputStream(byteData);
        Document document = docBuilder.parse(is);
    
        org.w3c.dom.Attr namespace = document.createAttribute("xmlns:exoks");
        namespace.setValue("http://www.exoplatform.com/exoks/2.0");
        document.getFirstChild().getAttributes().setNamedItem(namespace);
    
        org.w3c.dom.Attr attName = document.createAttribute("exoks:applicationName");
        attName.setValue(appName);// w  w  w . j  a  v  a2  s .co  m
        document.getFirstChild().getAttributes().setNamedItem(attName);
    
        org.w3c.dom.Attr dataType = document.createAttribute("exoks:objectType");
        dataType.setValue(objectType);
        document.getFirstChild().getAttributes().setNamedItem(dataType);
    
        org.w3c.dom.Attr exportDate = document.createAttribute("exoks:exportDate");
        exportDate.setValue(createDate.toString());
        document.getFirstChild().getAttributes().setNamedItem(exportDate);
    
        org.w3c.dom.Attr checkSum = document.createAttribute("exoks:checkSum");
        checkSum.setValue(generateCheckSum(byteData));
        document.getFirstChild().getAttributes().setNamedItem(checkSum);
    
        DOMSource source = new DOMSource(document.getFirstChild());
    
        File file = new File(fileName + ".xml");
        file.deleteOnExit();
        file.createNewFile();
        StreamResult result = new StreamResult(file);
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        transformer.transform(source, result);
        return file;
    }
    

    From source file:org.fcrepo.kernel.FedoraResource.java

    /**
     * Construct an ETag value from the last modified date and path. JCR has a
     * mix:etag type, but it only takes into account binary properties. We
     * actually want whole-object etag data. TODO : construct and store an ETag
     * value on object modify/*from w w  w  .  j  a  v  a 2 s .c om*/
     *
     * @return
     * @throws RepositoryException
     */
    public String getEtagValue() throws RepositoryException {
        final Date lastModifiedDate = getLastModifiedDate();
    
        if (lastModifiedDate != null) {
            return shaHex(node.getPath() + lastModifiedDate.toString());
        } else {
            return "";
        }
    }
    

    From source file:org.eclipse.jubula.client.core.businessprocess.AbstractXMLReportGenerator.java

    /**
     * Generates the basic, generic information for an XML report.
     * //from  www.  j  a  v  a 2  s .co m
     * @return The "project" element of the XML document.
     */
    protected Element generateHeader() {
        if (LOG.isInfoEnabled()) {
            LOG.info("Generating Result XML Report"); //$NON-NLS-1$
        }
    
        m_document.normalize();
        m_document.addComment("<?xml-stylesheet type=\"text/xsl\" href=\"format.xsl\"?>"); //$NON-NLS-1$
    
        Element root = m_document.addElement("report"); //$NON-NLS-1$
        root.addAttribute("style", getStyleName()); //$NON-NLS-1$
        Element general = root.addElement("project"); //$NON-NLS-1$
    
        general.addElement("name").//$NON-NLS-1$
                addText(getTestResult().getProjectName());
    
        general.addElement("version").//$NON-NLS-1$
                addText(getTestResult().getProjectMajorVersion() + StringConstants.DOT
                        + getTestResult().getProjectMinorVersion());
    
        Date startTime = getTestResult().getStartTime();
        if (startTime != null) {
            general.addElement("test-start").addText(startTime.toString()); //$NON-NLS-1$
        }
        Date endTime = getTestResult().getEndTime();
        if (endTime != null) {
            general.addElement("test-end").addText(endTime.toString()); //$NON-NLS-1$
        }
    
        if (startTime != null && endTime != null) {
            general.addElement("test-length").//$NON-NLS-1$
                    addText(TimeUtil.getDurationString(startTime, endTime));
        }
    
        addStepCountElements(getTestResult(), general);
    
        general.addElement("language").addText(getTestResult().getTestLanguage()); //$NON-NLS-1$
    
        return general;
    }
    

    From source file:org.codehaus.grepo.statistics.collection.SimpleStatisticsCollectionPrinter.java

    /**
     * @param date The date to format.//from   ww w. j a  va 2s.  c o  m
     * @return Returns the date as string.
     */
    private String formatDate(Date date) {
        String result = "";
        if (date != null) {
            result = (dateFormat == null ? date.toString() : dateFormat.format(date));
        }
        return result;
    }
    

    From source file:org.kie.workbench.common.forms.integration.tests.valueprocessing.FormValuesProcessorTest.java

    @Test
    public void testTextAreaTaskFormValuesProcessing() throws ParseException {
        setupFormValuesProcessor(Collections.singletonList(textAreaFormFieldValueProcessor));
    
        final String FIELD_BINDING = "_textarea";
    
        //raw value of the property before it was updated
        final Date d1 = createDate("21/12/2012");
        final Map<String, Object> originalRawValues = Collections.singletonMap(FIELD_BINDING, d1);
        //values in the form updated by user
        final Map<String, Object> originalFlatValues = Collections.singletonMap(FIELD_BINDING, d1.toString());
    
        final Map<String, Object> writtenRawValues = formValuesProcessor.writeFormValues(textAreaTaskForm,
                originalFlatValues, originalRawValues, context);
        testReadingFormValues(textAreaTaskForm, writtenRawValues, originalFlatValues);
        //note: in this case it doesn't make sense to test the writeFormValues method, since it returns flatValues
        //(there is no way to reconstruct the Object back from the String value)
    }
    

    From source file:com.miragedev.mononara.core.service.MononaraServiceImpl.java

    /**
     * Load the study list into the system.//  w w w . j  a  v a2  s. co  m
     * The process discard the old one.
     */
    public boolean onlineSync() {
        Date lastUpdate = kanjiService.findLastUpdate();
        //todo : need to add thelastUpdate for Dictionnary
        if (lastUpdate == null) {
            Calendar cal = Calendar.getInstance();
            cal.set(1999, 11, 31);
            lastUpdate = cal.getTime();
        }
        log.info("Last sucessful sync was :" + lastUpdate.toString());
        SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd");
        String lastUpdateAsString = dFormat.format(lastUpdate);
    
        /* Import the kanjis */
        importKanjisAndTags(lastUpdateAsString);
    
        /* Import the dictionary entries */
        importDictionaryAndTags(lastUpdateAsString);
    
        return true;
    
    }
    

    From source file:org.dspace.xoai.app.XOAI.java

    private int index(Date last) throws DSpaceSolrIndexerException {
        System.out.println("Incremental import. Searching for documents modified after: " + last.toString());
    
        String sqlQuery = "SELECT item_id FROM item WHERE in_archive=TRUE AND last_modified > ?";
        if (DatabaseManager.isOracle()) {
            sqlQuery = "SELECT item_id FROM item WHERE in_archive=1 AND last_modified > ?";
        }/*from  www. ja va 2 s . co m*/
    
        try {
            TableRowIterator iterator = DatabaseManager.query(_context, sqlQuery,
                    new java.sql.Timestamp(last.getTime()));
            return this.index(iterator);
        } catch (SQLException ex) {
            throw new DSpaceSolrIndexerException(ex.getMessage(), ex);
        }
    }
    

    From source file:org.flite.cach3.test.dao.TestDAOImpl.java

    @ReadThroughSingleCache(namespace = DATE_NAMESPACE, keyIndex = 0, expiration = 30)
    public String getDateString(final String key) {
        final Date now = new Date();
        try {//from  ww w.  ja va2  s. co m
            Thread.sleep(1500);
        } catch (InterruptedException ex) {
        }
        return now.toString() + ":" + now.getTime();
    }