List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:edu.utah.further.mdr.ws.api.to.AssetToImpl.java
/** * @return//from w w w .j a va 2 s . co m * @see edu.utah.further.mdr.api.domain.asset.Asset#getActivationTime() */ @Override public Long getActivationTime() { final Timestamp ts = getActivationDate(); return (ts == null) ? null : new Long(ts.getTime()); }
From source file:edu.utah.further.mdr.ws.api.to.AssetToImpl.java
/** * @return/*from ww w .j a v a2s . c om*/ * @see edu.utah.further.mdr.api.domain.asset.Asset#getDeactivationTime() */ @Override public Long getDeactivationTime() { final Timestamp ts = getDeactivationDate(); return (ts == null) ? null : new Long(ts.getTime()); }
From source file:org.etk.entity.engine.plugins.transaction.TransactionUtil.java
public static Timestamp getTransactionUniqueNowStamp() { Timestamp lastNowStamp = transactionLastNowStamp.get(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); // check for an overlap with the lastNowStamp, or if the lastNowStamp is in // the future because of incrementing to make each stamp unique if (lastNowStamp != null && (lastNowStamp.equals(nowTimestamp) || lastNowStamp.after(nowTimestamp))) { nowTimestamp = new Timestamp(lastNowStamp.getTime() + 1); }// w w w . j a va 2s. c o m transactionLastNowStamp.set(nowTimestamp); return nowTimestamp; }
From source file:com.rogchen.common.xml.UtilDateTime.java
/** * ? Timestamp /*from ww w .j a va 2s . c o m*/ * * @param from * @param thru * @return */ public static double getInterval(Timestamp from, Timestamp thru) { return thru != null ? thru.getTime() - from.getTime() + (thru.getNanos() - from.getNanos()) / 1000000 : 0; }
From source file:org.isatools.isatab_v1.IconixPersistenceTest.java
@SuppressWarnings("static-access") @Test/*from w ww. j a va2 s.c o m*/ public void testPersistence() throws Exception { out.println("\n\n_______________________ Iconix Case Persistence Test _______________________\n\n"); String baseDir = System.getProperty("basedir"); String filesPath = baseDir + "/target/test-classes/test-data/isatab/isatab_v1_200810/iconix_20081107red"; ISATABLoader loader = new ISATABLoader(filesPath); FormatSetInstance isatabInstance = loader.load(); out.println("\n\n_____ Loaded, now mapping"); BIIObjectStore store = new BIIObjectStore(); ISATABMapper isatabMapper = new ISATABMapper(store, isatabInstance); isatabMapper.map(); assertTrue("Oh no! No mapped object! ", store.size() > 0); out.println("\n_____________ Persisting"); // Test the repository too String repoPath = baseDir + "/target/bii_test_repo/meta_data"; File repoDir = new File(repoPath); if (!repoDir.exists()) { FileUtils.forceMkdir(repoDir); } ISATABPersister persister = new ISATABPersister(store, DaoFactory.getInstance(entityManager)); Timestamp ts = persister.persist(filesPath); transaction.commit(); for (Study study : store.valuesOfType(Study.class)) { assertTrue("Oh no! Submission didn't go to the repository!", new File(repoPath + "/study_" + DataLocationManager.getObfuscatedStudyFileName(study)) .exists()); } out.println("\n\n\n\n________________ Done, Submission TS: " + ts.getTime() + " (" + ts + " + " + ts.getNanos() + "ns)"); out.println("\n\n___________________ /end: Iconix Case Persistence Test ___________________\n\n"); }
From source file:it.geosolutions.geobatch.destination.ingestion.gate.GateIngestionMemoryTest.java
/** * Check if exists one transit with all data in the data store * /*from w w w . j a va2s . c o m*/ * @param idTransit id of the transit in the data store * @param transit bean with the data * @throws Exception */ private void checkData(Long idTransit, Transit transit) throws Exception { @SuppressWarnings("rawtypes") FeatureCollection fc = dataStore.getFeatureSource("siig_gate_t_dato").getFeatures(); @SuppressWarnings("unchecked") FeatureIterator<Feature> fi = fc.features(); boolean found = false; while (fi.hasNext()) { Feature feature = fi.next(); // check common data if (feature.getProperty("id_dato").getValue().toString().equals(idTransit.toString()) && feature.getProperty("flg_corsia").getValue().toString() .equals(transit.getCorsia().toString()) && feature.getProperty("flg_direzione").getValue().toString().equals(transit.getDirezione()) && feature.getProperty("codice_onu").getValue().toString().equals(transit.getOnuCode())) { // check dates Timestamp arriveDate = (Timestamp) feature.getProperty("data_rilevamento").getValue(); Object receiptDate = feature.getProperty("data_ricezione").getValue(); if (timeFormat.getTimeStamp(transit.getDataRilevamento()).getTime() == arriveDate.getTime() && timeFormat.isToday(receiptDate.toString())) { found = true; break; } } } assertTrue(found); }
From source file:org.cloudgraph.rdb.service.RDBDataConverter.java
private Object convertFrom(ResultSet rs, int columnIndex, int sourceType, Property property) throws SQLException { Object result = null;/*w ww. java 2s .co m*/ if (!property.getType().isDataType()) throw new IllegalArgumentException("expected data type property, not " + property.toString()); DataType targetDataType = DataType.valueOf(property.getType().getName()); switch (targetDataType) { case String: case URI: case Month: case MonthDay: case Day: case Time: case Year: case YearMonth: case YearMonthDay: case Duration: result = rs.getString(columnIndex); break; case Date: java.sql.Timestamp ts = rs.getTimestamp(columnIndex); if (ts != null) result = new java.util.Date(ts.getTime()); break; case DateTime: ts = rs.getTimestamp(columnIndex); if (ts != null) { // format DateTime String for SDO java.util.Date date = new java.util.Date(ts.getTime()); result = DataConverter.INSTANCE.getDateTimeFormat().format(date); } break; case Decimal: result = rs.getBigDecimal(columnIndex); break; case Bytes: if (sourceType != Types.BLOB) { result = rs.getBytes(columnIndex); } else if (sourceType == Types.BLOB) { Blob blob = rs.getBlob(columnIndex); if (blob != null) { long blobLen = blob.length(); // for debugging // Note: blob.getBytes(columnIndex, blob.length()); is // somehow truncating the array // by something like 14 bytes (?!!) even though // blob.length() returns the expected length // using getBinaryStream which is preferred anyway InputStream is = blob.getBinaryStream(); try { byte[] bytes = IOUtils.toByteArray(is); long len = bytes.length; // for debugging result = bytes; } catch (IOException e) { throw new RDBServiceException(e); } finally { try { is.close(); } catch (IOException e) { log.error(e.getMessage(), e); } } } } break; case Byte: result = rs.getByte(columnIndex); break; case Boolean: result = rs.getBoolean(columnIndex); break; case Character: result = rs.getInt(columnIndex); break; case Double: result = rs.getDouble(columnIndex); break; case Float: result = rs.getFloat(columnIndex); break; case Int: result = rs.getInt(columnIndex); break; case Integer: result = new BigInteger(rs.getString(columnIndex)); break; case Long: result = rs.getLong(columnIndex); break; case Short: result = rs.getShort(columnIndex); break; case Strings: String value = rs.getString(columnIndex); if (value != null) { String[] values = value.split("\\s"); List<String> list = new ArrayList<String>(values.length); for (int i = 0; i < values.length; i++) list.add(values[i]); // what no Java 5 sugar for this ?? result = list; } break; case Object: default: result = rs.getObject(columnIndex); break; } return result; }
From source file:com.rogchen.common.xml.UtilDateTime.java
/** * ? ()//from ww w . java 2 s . c om * * @param from * @param thru * @return */ public static int getIntervalInDays(Timestamp from, Timestamp thru) { return thru != null ? (int) ((thru.getTime() - from.getTime()) / (24 * 60 * 60 * 1000)) : 0; }
From source file:com.rogchen.common.xml.UtilDateTime.java
public static Timestamp addDaysToTimestamp(Timestamp start, int days) { return new Timestamp(start.getTime() + (24L * 60L * 60L * 1000L * days)); }
From source file:de.micromata.genome.logging.spi.ifiles.IndexDirectory.java
public List<String> getLogFileCandiates(Timestamp start, Timestamp end) { TreeMap<Long, String> files = new TreeMap<>(); // int offset = HEADER_SIZE; int max = getWritePos() - ROW_SIZE; int offset = max; while (offset >= HEADER_SIZE) { long st = indexByteBuffer.getLong(offset); if (start != null) { if (st < start.getTime()) { offset -= ROW_SIZE;//from w ww . j a va 2 s . c om continue; } } if (end != null) { long et = indexByteBuffer.getLong(offset + Long.BYTES); if (et > end.getTime()) { offset -= ROW_SIZE; continue; } } indexByteBuffer.position(offset + Long.BYTES + Long.BYTES); byte[] nameBuffer = new byte[LOG_FILE_NAME_SIZE]; indexByteBuffer.get(nameBuffer); String trimmed = new String(nameBuffer).trim(); files.put(st, trimmed); offset -= ROW_SIZE; } List<String> ret = new ArrayList<>(files.values()); return ret; }