List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:net.sourceforge.vulcan.spring.jdbc.ChangeSetQuery.java
@Override protected ChangeSetDto mapRow(ResultSet rs, int rowNumber) throws SQLException { final ChangeSetDto dto = new ChangeSetDto(); dto.setMessage(rs.getString("message")); dto.setAuthorName(rs.getString("author")); dto.setAuthorEmail(rs.getString("author_email")); dto.setRevisionLabel(rs.getString("revision_label")); final Timestamp timestamp = rs.getTimestamp("commit_timestamp"); if (!rs.wasNull()) { dto.setTimestamp(new Date(timestamp.getTime())); }// w w w. j a va2s.co m int buildId = rs.getInt("build_id"); int changeSetId = rs.getInt("change_set_id"); final List<ModifiedPathDto> paths = modifiedPathQuery.queryModifiedPaths(buildId, changeSetId); dto.setModifiedPaths(paths); return dto; }
From source file:de.heartbeat.charts.YearOverview.java
private List<Point> getPoints(List<HeartBeat> hbList) { List<Point> points = new ArrayList<>(); int y = 0;/*from w w w .j a v a 2s .c o m*/ for (int i = hbList.size() - 1; i >= 0; i--) { Timestamp ts = hbList.get(i).getTime(); Date time = new Date(ts.getTime()); // some bug in charts or sth. time = DateUtils.addHours(time, 1); long timeL = time.getTime(); points.add(new Point().setX(timeL).setY(Double.parseDouble(hbList.get(i).getPulse()))); } return points; }
From source file:org.kuali.rice.ksb.messaging.exceptionhandling.DefaultMessageExceptionHandler.java
protected void requeue(Throwable throwable, PersistedMessageBO message) throws Exception { Integer retryCount = message.getRetryCount(); message.setQueueStatus(KSBConstants.ROUTE_QUEUE_QUEUED); long addMilliseconds = Math.round(getTimeIncrement() * Math.pow(2, retryCount)); Timestamp currentTime = message.getQueueDate(); Timestamp newTime = new Timestamp(currentTime.getTime() + addMilliseconds); message.setQueueStatus(KSBConstants.ROUTE_QUEUE_QUEUED); message.setRetryCount(new Integer(retryCount + 1)); message.setQueueDate(newTime);// w ww .j a v a2 s.c om scheduleExecution(throwable, message); }
From source file:org.apache.hadoop.hive.ql.udf.generic.GenericUDFFromUtcTimestamp.java
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Object o0 = arguments[0].get(); if (o0 == null) { return null; }/*from w w w. j a v a 2 s . co m*/ Object o1 = arguments[1].get(); if (o1 == null) { return null; } String tzStr = textConverter.convert(o1).toString(); TimeZone timezone = TimeZone.getTimeZone(tzStr); Timestamp timestamp = ((TimestampWritable) timestampConverter.convert(o0)).getTimestamp(); int offset = timezone.getOffset(timestamp.getTime()); if (invert()) { offset = -offset; } return applyOffset(offset, timestamp); }
From source file:com.joe.utilities.core.hibernate.repository.impl.ApplicationConfigurationRepositoryImpl.java
public Long retrieveDBTimeInMilliseconds() { DbTimestampType type = new DbTimestampType(); Timestamp ts = (Timestamp) type.seed((SessionImplementor) getSession()); return ts.getTime(); }
From source file:org.apdplat.superword.tools.MySQLUtils.java
public static List<MyNewWord> getMyNewWordsFromDatabase(String userName) { List<MyNewWord> myNewWords = new ArrayList<>(); String sql = "select word,date_time from my_new_words where user_name=? order by date_time desc"; Connection con = getConnection(); if (con == null) { return myNewWords; }/*from w ww . j av a 2s . co m*/ PreparedStatement pst = null; ResultSet rs = null; try { pst = con.prepareStatement(sql); pst.setString(1, userName); rs = pst.executeQuery(); while (rs.next()) { String word = rs.getString(1); Timestamp timestamp = rs.getTimestamp(2); MyNewWord myNewWord = new MyNewWord(); myNewWord.setWord(word); myNewWord.setDateTime(new java.util.Date(timestamp.getTime())); myNewWord.setUserName(userName); myNewWords.add(myNewWord); } } catch (SQLException e) { LOG.error("", e); } finally { close(con, pst, rs); } return myNewWords; }
From source file:org.openhie.openempi.util.DateConverterTest.java
public void testConvertStringToTimestamp() throws Exception { Date today = new Date(); Calendar todayCalendar = new GregorianCalendar(); todayCalendar.setTime(today);//from w w w . j av a 2 s . c o m String datePart = DateUtil.convertDateToString(today); Timestamp time = (Timestamp) converter.convert(Timestamp.class, datePart + " 01:02:03.4"); Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(time.getTime()); assertEquals(todayCalendar.get(Calendar.YEAR), cal.get(Calendar.YEAR)); assertEquals(todayCalendar.get(Calendar.MONTH), cal.get(Calendar.MONTH)); assertEquals(todayCalendar.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH)); }
From source file:com.smartsheet.tin.filters.common.FilterMetrics.java
/** * Register the timestamp of the event./*from w w w . j a va 2s . c o m*/ * @param event_ts */ public void eventTimestamp(Timestamp event_ts) { this.currentEventTS = event_ts.getTime(); }
From source file:com.google.enterprise.connector.db.diffing.JsonObjectUtil.java
/** * Adds the last modified date property to the JSON Object. * * @param propertyName// w ww.ja v a 2 s . c om * @param propertyValue */ public void setLastModifiedDate(String propertyName, Timestamp propertyValue) { if (propertyValue != null) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(propertyValue.getTime()); Value value = Value.getDateValue(cal); properties.put(propertyName, ImmutableList.of(value)); try { jsonObject.put(propertyName, value.toString()); } catch (JSONException e) { LOG.warning("Exception for " + propertyName + " with value " + propertyValue + "\n" + e.toString()); } } }
From source file:com.wabacus.system.datatype.CTimestampType.java
public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException { java.sql.Timestamp cts = rs.getTimestamp(column); if (cts == null) return null; Calendar cd = Calendar.getInstance(); cd.setTimeInMillis(cts.getTime()); return cd;/*from w ww.j a v a2 s .c om*/ }