/** * Sets a default creation date. If the named file exists, then the creation * date is set to the file's last modification date. Otherwise, it is set * to the current date. * * @see #setDefaultDateEnabled(boolean) */ public static void setDefaultCreationDate(MetadataStore store, String id, int series) { if (!defaultDateEnabled) { return; } Location file = id == null ? null : new Location(id).getAbsoluteFile(); long time = System.currentTimeMillis(); if (file != null && file.exists()) time = file.lastModified(); store.setImageAcquisitionDate(new Timestamp(DateTools.convertDate( time, DateTools.UNIX)), series); }
/** * Sets a default creation date. If the named file exists, then the creation * date is set to the file's last modification date. Otherwise, it is set * to the current date. * * @see #setDefaultDateEnabled(boolean) */ public static void setDefaultCreationDate(MetadataStore store, String id, int series) { if (!defaultDateEnabled) { return; } Location file = id == null ? null : new Location(id).getAbsoluteFile(); long time = System.currentTimeMillis(); if (file != null && file.exists()) time = file.lastModified(); store.setImageAcquisitionDate(new Timestamp(DateTools.convertDate( time, DateTools.UNIX)), series); }
long modTime = new Location(currentId).getAbsoluteFile().lastModified(); String year = DateTools.convertDate(modTime, DateTools.UNIX, "yyyy"); date = value.replaceAll("'", "") + " " + year;
long realLast = realFile.lastModified(); if (memoLast < realLast) { LOGGER.debug("memo(lastModified={}) older than real(lastModified={})",
long modTime = new Location(currentId).getAbsoluteFile().lastModified(); String year = DateTools.convertDate(modTime, DateTools.UNIX, "yyyy"); date = value.replaceAll("'", "") + " " + year;
long realLast = realFile.lastModified(); if (memoLast < realLast) { LOGGER.debug("memo(lastModified={}) older than real(lastModified={})",
private long getTimestamp(String file) throws FormatException, IOException { try (RandomAccessInputStream s = new RandomAccessInputStream(file, 16)) { TiffParser parser = new TiffParser(s); parser.setDoCaching(false); IFD firstIFD = parser.getFirstIFD(); if (firstIFD != null) { TiffIFDEntry timestamp = (TiffIFDEntry) firstIFD.get(IFD.DATE_TIME); if (timestamp != null) { String stamp = parser.getIFDValue(timestamp).toString(); stamp = DateTools.formatDate(stamp, BaseTiffReader.DATE_FORMATS, "."); Timestamp t = Timestamp.valueOf(stamp); return t.asInstant().getMillis(); // NPE if invalid input. } } } return new Location(file).lastModified(); }
private long getTimestamp(String file) throws FormatException, IOException { try (RandomAccessInputStream s = new RandomAccessInputStream(file, 16)) { TiffParser parser = new TiffParser(s); parser.setDoCaching(false); IFD firstIFD = parser.getFirstIFD(); if (firstIFD != null) { TiffIFDEntry timestamp = (TiffIFDEntry) firstIFD.get(IFD.DATE_TIME); if (timestamp != null) { String stamp = parser.getIFDValue(timestamp).toString(); stamp = DateTools.formatDate(stamp, BaseTiffReader.DATE_FORMATS, "."); Timestamp t = Timestamp.valueOf(stamp); return t.asInstant().getMillis(); // NPE if invalid input. } } } return new Location(file).lastModified(); }
long saneDate = new Timestamp("1990-01-01T00:00:00").asInstant().getMillis(); long fileDate = new Location( reader.getCurrentFile()).getAbsoluteFile().lastModified(); if (acquiredDate < saneDate && fileDate >= saneDate) { msg = "CreationDate (date=" + date + " acquiredDate=" + acquiredDate + " fileDate=" + fileDate + " saneDate=" + saneDate + ")";