List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:com.wabacus.system.datatype.TimestampType.java
public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException { java.sql.Timestamp ts = rs.getTimestamp(iindex); if (ts == null) return null; return new Date(ts.getTime()); }
From source file:org.apache.hive.storage.jdbc.spitter.TimestampIntervalSplitter.java
@Override public List<MutablePair<String, String>> getIntervals(String lowerBound, String upperBound, int numPartitions, TypeInfo typeInfo) {/* w w w . j a v a 2 s .c om*/ List<MutablePair<String, String>> intervals = new ArrayList<>(); Timestamp timestampLower = Timestamp.valueOf(lowerBound); Timestamp timestampUpper = Timestamp.valueOf(upperBound); // Note nano is not fully represented as the precision limit double timestampInterval = (timestampUpper.getTime() - timestampLower.getTime()) / (double) numPartitions; Timestamp splitTimestampLower, splitTimestampUpper; for (int i = 0; i < numPartitions; i++) { splitTimestampLower = new Timestamp(Math.round(timestampLower.getTime() + timestampInterval * i)); splitTimestampUpper = new Timestamp(Math.round(timestampLower.getTime() + timestampInterval * (i + 1))); if (splitTimestampLower.compareTo(splitTimestampUpper) < 0) { intervals.add(new MutablePair<String, String>(splitTimestampLower.toString(), splitTimestampUpper.toString())); } } return intervals; }
From source file:com.impetus.kundera.property.accessor.SQLTimestampAccessor.java
@Override public Timestamp getCopy(Object object) { Timestamp ts = (Timestamp) object; return ts != null ? new Timestamp(ts.getTime()) : null; }
From source file:org.cloudfoundry.identity.uaa.codestore.InMemoryExpiringCodeStore.java
@Override public ExpiringCode generateCode(String data, Timestamp expiresAt) { if (data == null || expiresAt == null) { throw new NullPointerException(); }//from www .j a v a 2s . co m if (expiresAt.getTime() < System.currentTimeMillis()) { throw new IllegalArgumentException(); } String code = generator.generate(); ExpiringCode expiringCode = new ExpiringCode(code, expiresAt, data); ExpiringCode duplicate = store.putIfAbsent(code, expiringCode); if (duplicate != null) { throw new DataIntegrityViolationException("Duplicate code: " + code); } return expiringCode; }
From source file:DateUtils.java
/** * Convert timestamp to string including it's nanosecond portion so that it * can be safely stored in variable of web page. * // w ww .ja v a 2 s .co m * @param tsTimestamp - timestamp to convert * @return String - text containing time and nanosecond portion of timestamp */ public static String getTimestampAsString(Timestamp tsTimestamp) { StringBuffer sbTimestamp = new StringBuffer(); sbTimestamp.append(tsTimestamp.getTime()); sbTimestamp.append(NANO_SEPARATOR); sbTimestamp.append(tsTimestamp.getNanos()); return sbTimestamp.toString(); }
From source file:tianci.pinao.dts.dao.impl.ConfigDaoImpl.java
@Override public Config mapRow(ResultSet rs, int index) throws SQLException { Config config = new Config(); config.setId(rs.getInt("id")); config.setType(rs.getInt("type")); config.setValue(rs.getLong("value")); Timestamp ts = rs.getTimestamp("lastmod_time"); if (ts != null) config.setLastModTime(new Date(ts.getTime())); config.setLastModUserid(rs.getInt("lastmod_userid")); return config; }
From source file:tianci.pinao.dts.dao.impl.ConfigDaoImpl.java
@Override public License mapRow(ResultSet rs, int index) throws SQLException { License license = new License(); license.setId(rs.getInt("id")); license.setMac(rs.getString("mac")); license.setUseTime(rs.getLong("use_time")); Timestamp ts = rs.getTimestamp("lastmod_time"); if (ts != null) license.setLastModTime(new Date(ts.getTime())); license.setLastModUserid(rs.getInt("lastmod_userid")); return license; }
From source file:fr.mby.opa.pics.model.converter.TimestampJsonSerializer.java
@Override public void serialize(final Timestamp value, final JsonGenerator gen, final SerializerProvider arg2) throws IOException, JsonProcessingException { if (value != null) { gen.writeNumber(value.getTime()); }//from w w w . j a v a 2 s . co m }
From source file:dk.netarkivet.common.utils.DBUtils.java
/** * Get a Date from a column in the resultset. * Returns null, if the value in the column is NULL. * @param rs the resultSet//from w w w .j av a 2 s .com * @param columnIndex The given column, where the Date resides * @return a Date from a column in the resultset * @throws SQLException If columnIndex does not correspond to a * parameter marker in the ResultSet, or a database access error * occurs or this method is called on a closed ResultSet */ public static Date getDateMaybeNull(ResultSet rs, final int columnIndex) throws SQLException { ArgumentNotValid.checkNotNull(rs, "ResultSet rs"); ArgumentNotValid.checkNotNegative(columnIndex, "int columnIndex"); final Timestamp startTimestamp = rs.getTimestamp(columnIndex); if (rs.wasNull()) { return null; } Date startdate; if (startTimestamp != null) { startdate = new Date(startTimestamp.getTime()); } else { startdate = null; } return startdate; }
From source file:tianci.pinao.dts.tasks.dao.impl.ConfigDaoImpl.java
@Override public Map<Integer, Config> getConfigs() { final Map<Integer, Config> configs = new HashMap<Integer, Config>(); getJdbcTemplate().query("select id, type, value, lastmod_time, lastmod_userid from " + SqlConstants.TABLE_CONFIG + " where isdel = ?", new Object[] { 0 }, new RowMapper<Config>() { @Override/*from www .j ava 2 s . c o m*/ public Config mapRow(ResultSet rs, int index) throws SQLException { Config config = new Config(); config.setId(rs.getInt("id")); config.setType(rs.getInt("type")); config.setValue(rs.getLong("value")); Timestamp ts = rs.getTimestamp("lastmod_time"); if (ts != null) config.setLastModTime(new Date(ts.getTime())); config.setLastModUserid(rs.getInt("lastmod_userid")); configs.put(config.getType(), config); return config; } }); return configs; }