List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:edu.utah.further.mdr.ws.api.to.ActivationInfoToImpl.java
/** * @param other//from w w w . ja v a 2 s . c o m * @return * @see edu.utah.further.mdr.api.domain.asset.ActivationInfo#copyFrom(edu.utah.further.mdr.api.domain.asset.ActivationInfo) */ @Override public ActivationInfoToImpl copyFrom(final ActivationInfo other) { if (other == null) { return this; } // Identifier is not copied // Deep-copy fields final Timestamp otherActivationDate = other.getActivationDate(); if (otherActivationDate != null) { this.activationDate = new Timestamp(otherActivationDate.getTime()); } final Timestamp otherDeactivationDate = other.getDeactivationDate(); if (otherDeactivationDate != null) { this.deactivationDate = new Timestamp(otherDeactivationDate.getTime()); } // Deep-copy collection references but soft-copy their elements return this; }
From source file:libepg.epg.section.body.eventinformationtable.EventInformationTableRepeatingPartTest.java
@Test public void fail_tomestamp_ffff() throws DecoderException, InvocationTargetException { LOG.info("???null?????"); String data = "7f61e111115400ffffff00164d0d6a706e0835243e5d3e704a7300540201ffc10188"; EventInformationTableRepeatingPart instance = init(Hex.decodeHex(data.toCharArray())); Timestamp st = instance.getStart_time_Object(); assertEquals(1471402440000L, st.getTime()); Timestamp en = instance.getStop_Time_Object(); assertEquals(en, null);//from w w w.j a v a 2 s .c om }
From source file:net.sourceforge.vulcan.spring.jdbc.BuildQuery.java
@Override protected JdbcBuildOutcomeDto mapRow(ResultSet rs, int rowNumber) throws SQLException { final JdbcBuildOutcomeDto dto = new JdbcBuildOutcomeDto(); dto.setPrimaryKey(rs.getInt("id")); dto.setName(rs.getString("name")); dto.setId(UUID.fromString(rs.getString("uuid"))); dto.setStatus(ProjectStatusDto.Status.valueOf(rs.getString("status"))); dto.setMessageKey(rs.getString("message_key")); dto.setBuildReasonKey(rs.getString("build_reason_key")); dto.setStartDate(new Date(rs.getTimestamp("start_date").getTime())); dto.setCompletionDate(new Date(rs.getTimestamp("completion_date").getTime())); dto.setBuildNumber(rs.getInt("build_number")); dto.setWorkDir(rs.getString("work_dir")); dto.setWorkDirSupportsIncrementalUpdate(rs.getBoolean("work_dir_vcs_clean")); dto.setTagName(rs.getString("tag_name")); dto.setRepositoryUrl(rs.getString("repository_url")); dto.setScheduledBuild(rs.getBoolean("scheduled_build")); dto.setStatusChanged(rs.getBoolean("status_changed")); dto.setRequestedBy(rs.getString("requested_by")); dto.setBrokenBy(rs.getString("broken_by_user_name")); final Timestamp claimed_date = rs.getTimestamp("claimed_date"); if (StringUtils.isNotBlank(dto.getBrokenBy()) && !rs.wasNull()) { dto.setClaimDate(new Date(claimed_date.getTime())); }//from w w w . jav a2 s. co m final String updateTypeString = rs.getString("update_type"); if (!rs.wasNull() && StringUtils.isNotEmpty(updateTypeString)) { dto.setUpdateType(ProjectStatusDto.UpdateType.valueOf(updateTypeString)); } else { dto.setUpdateType(null); } final Integer lastGoodBuildNumber = rs.getInt("last_good_build_number"); if (!rs.wasNull()) { dto.setLastGoodBuildNumber(lastGoodBuildNumber); } final Long revision = rs.getLong("revision"); if (!rs.wasNull()) { final RevisionTokenDto revisionTokenDto = new RevisionTokenDto(revision, rs.getString("revision_label")); if (rs.getBoolean("revision_unavailable")) { dto.setLastKnownRevision(revisionTokenDto); } else { dto.setRevision(revisionTokenDto); } } dto.setMessageArgs(mapMessageArgs(rs, "message_arg_")); dto.setBuildReasonArgs(mapMessageArgs(rs, "build_reason_arg_")); return dto; }
From source file:nl.edia.xapi.proxy.impl.TestObjectBuilder.java
public Result buildResult(Object target) { Result result = null;// w ww .j av a 2 s.c om if (target instanceof TestResult) { TestResult testResult = (TestResult) target; result = new Result(); result.setCompletion(testResult.isFinished()); Score score = new Score(); score.setScaled((float) testResult.getPercCorrect()); result.setScore(score); Timestamp starttime = testResult.getStarttime(); Timestamp endtime = testResult.getEndtime(); if (starttime != null && endtime != null) { Duration duration = new Duration(starttime.getTime(), endtime.getTime()); result.setDuration(ISOPeriodFormat.standard().print(duration.toPeriod())); } } return result; }
From source file:org.apdplat.superword.tools.MySQLUtils.java
public static UserText getUseTextFromDatabase(int id) { String sql = "select id,text,date_time,user_name from user_text where id=?"; Connection con = getConnection(); if (con == null) { return null; }/*from w w w . ja va2 s . co m*/ PreparedStatement pst = null; ResultSet rs = null; try { pst = con.prepareStatement(sql); pst.setInt(1, id); rs = pst.executeQuery(); if (rs.next()) { int _id = rs.getInt(1); String text = rs.getString(2); Timestamp timestamp = rs.getTimestamp(3); ; String user_name = rs.getString(4); UserText userText = new UserText(); userText.setId(id); userText.setText(text); userText.setDateTime(new java.util.Date(timestamp.getTime())); userText.setUserName(user_name); return userText; } } catch (SQLException e) { LOG.error("", e); } finally { close(con, pst, rs); } return null; }
From source file:org.jfree.data.jdbc.JDBCPieDataset.java
/** * ExecuteQuery will attempt execute the query passed to it against the * existing database connection. If no connection exists then no action * is taken./*ww w . j a v a 2s .c o m*/ * The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query to be executed * @param con the connection the query is to be executed against * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(Connection con, String query) throws SQLException { Statement statement = null; ResultSet resultSet = null; try { statement = con.createStatement(); resultSet = statement.executeQuery(query); ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); if (columnCount != 2) { throw new SQLException("Invalid sql generated. PieDataSet requires 2 columns only"); } int columnType = metaData.getColumnType(2); double value = Double.NaN; while (resultSet.next()) { Comparable key = resultSet.getString(1); switch (columnType) { case Types.NUMERIC: case Types.REAL: case Types.INTEGER: case Types.DOUBLE: case Types.FLOAT: case Types.DECIMAL: case Types.BIGINT: value = resultSet.getDouble(2); setValue(key, value); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: Timestamp date = resultSet.getTimestamp(2); value = date.getTime(); setValue(key, value); break; default: System.err.println("JDBCPieDataset - unknown data type"); break; } } fireDatasetChanged(new DatasetChangeInfo()); //TODO: fill in real change info } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { System.err.println("JDBCPieDataset: swallowing exception."); } } if (statement != null) { try { statement.close(); } catch (Exception e) { System.err.println("JDBCPieDataset: swallowing exception."); } } } }
From source file:de.powerstaff.business.dao.hibernate.StatistikDAOHibernateImpl.java
@Override public List<KontakthistorieEntry> kontakthistorie(final Date aDatumVon, final Date aDatumBis, final User aBenutzer) { return (List<KontakthistorieEntry>) getHibernateTemplate().execute(new HibernateCallback() { @Override//from w w w . j ava 2s . c om public Object doInHibernate(Session aSession) throws SQLException { List<KontakthistorieEntry> theResult = new ArrayList<KontakthistorieEntry>(); Conjunction theRestrictions = Restrictions.conjunction(); if (aDatumVon != null) { theRestrictions.add(Restrictions.ge("h.creationDate", aDatumVon)); } if (aDatumBis != null) { theRestrictions.add(Restrictions.le("h.creationDate", aDatumBis)); } if (aBenutzer != null) { theRestrictions.add(Restrictions.eq("h.creationUserID", aBenutzer.getUsername())); } // Freiberufler Criteria theCriteria = aSession.createCriteria(Freelancer.class, "p"); theCriteria.createCriteria("history", "h"); theCriteria.add(theRestrictions); ProjectionList theProjections = Projections.projectionList(); theProjections.add(Projections.property("p.name1")); theProjections.add(Projections.property("p.name2")); theProjections.add(Projections.property("p.code")); theProjections.add(Projections.property("h.creationDate")); theProjections.add(Projections.property("h.creationUserID")); theProjections.add(Projections.property("h.type")); theProjections.add(Projections.property("h.description")); theCriteria.setProjection(theProjections); for (Object theResultObject : theCriteria.list()) { Object[] theResultArray = (Object[]) theResultObject; KontakthistorieEntry theEntry = new KontakthistorieEntry(); theEntry.setName1((String) theResultArray[0]); theEntry.setName2((String) theResultArray[1]); theEntry.setCode((String) theResultArray[2]); Timestamp theTimestamp = (Timestamp) theResultArray[3]; theEntry.setDatum(new Date(theTimestamp.getTime())); theEntry.setUserid((String) theResultArray[4]); theEntry.setType((HistoryType) theResultArray[5]); theEntry.setDescription((String) theResultArray[6]); theResult.add(theEntry); } // Partner theCriteria = aSession.createCriteria(Partner.class, "p"); theCriteria.createCriteria("history", "h"); theCriteria.add(theRestrictions); theProjections = Projections.projectionList(); theProjections.add(Projections.property("p.name1")); theProjections.add(Projections.property("p.name2")); theProjections.add(Projections.property("h.creationDate")); theProjections.add(Projections.property("h.creationUserID")); theProjections.add(Projections.property("h.type")); theProjections.add(Projections.property("h.description")); theCriteria.setProjection(theProjections); for (Object theResultObject : theCriteria.list()) { Object[] theResultArray = (Object[]) theResultObject; KontakthistorieEntry theEntry = new KontakthistorieEntry(); theEntry.setName1((String) theResultArray[0]); theEntry.setName2((String) theResultArray[1]); Timestamp theTimestamp = (Timestamp) theResultArray[2]; theEntry.setDatum(new Date(theTimestamp.getTime())); theEntry.setUserid((String) theResultArray[3]); theEntry.setType((HistoryType) theResultArray[4]); theEntry.setDescription((String) theResultArray[5]); theResult.add(theEntry); } // Kunden theCriteria = aSession.createCriteria(Customer.class, "p"); theCriteria.createCriteria("history", "h"); theCriteria.add(theRestrictions); theProjections = Projections.projectionList(); theProjections.add(Projections.property("p.name1")); theProjections.add(Projections.property("p.name2")); theProjections.add(Projections.property("h.creationDate")); theProjections.add(Projections.property("h.creationUserID")); theProjections.add(Projections.property("h.type")); theProjections.add(Projections.property("h.description")); theCriteria.setProjection(theProjections); for (Object theResultObject : theCriteria.list()) { Object[] theResultArray = (Object[]) theResultObject; KontakthistorieEntry theEntry = new KontakthistorieEntry(); theEntry.setName1((String) theResultArray[0]); theEntry.setName2((String) theResultArray[1]); Timestamp theTimestamp = (Timestamp) theResultArray[2]; theEntry.setDatum(new Date(theTimestamp.getTime())); theEntry.setUserid((String) theResultArray[3]); theEntry.setType((HistoryType) theResultArray[4]); theEntry.setDescription((String) theResultArray[5]); theResult.add(theEntry); } Collections.sort(theResult, new ReverseComparator(new BeanComparator("datum"))); return theResult; } }); }
From source file:org.apdplat.superword.tools.MySQLUtils.java
public static List<UserDynamicPrefix> getHistoryUserDynamicPrefixesFromDatabase(String userName) { List<UserDynamicPrefix> userDynamicPrefixes = new ArrayList<>(); String sql = "select id,dynamic_prefix,date_time from user_dynamic_prefix where user_name=?"; Connection con = getConnection(); if (con == null) { return userDynamicPrefixes; }/* ww w .j a v a2s.c o m*/ PreparedStatement pst = null; ResultSet rs = null; try { pst = con.prepareStatement(sql); pst.setString(1, userName); rs = pst.executeQuery(); while (rs.next()) { int id = rs.getInt(1); String dynamicPrefix = rs.getString(2); Timestamp timestamp = rs.getTimestamp(3); UserDynamicPrefix userDynamicPrefix = new UserDynamicPrefix(); userDynamicPrefix.setId(id); userDynamicPrefix.setDynamicPrefix(dynamicPrefix); userDynamicPrefix.setDateTime(new java.util.Date(timestamp.getTime())); userDynamicPrefix.setUserName(userName); userDynamicPrefixes.add(userDynamicPrefix); } } catch (SQLException e) { LOG.error("", e); } finally { close(con, pst, rs); } return userDynamicPrefixes; }
From source file:org.apdplat.superword.tools.MySQLUtils.java
public static List<UserDynamicSuffix> getHistoryUserDynamicSuffixesFromDatabase(String userName) { List<UserDynamicSuffix> userDynamicSuffixes = new ArrayList<>(); String sql = "select id,dynamic_suffix,date_time from user_dynamic_suffix where user_name=?"; Connection con = getConnection(); if (con == null) { return userDynamicSuffixes; }/*from w w w .j a va 2 s . com*/ PreparedStatement pst = null; ResultSet rs = null; try { pst = con.prepareStatement(sql); pst.setString(1, userName); rs = pst.executeQuery(); while (rs.next()) { int id = rs.getInt(1); String dynamicSuffix = rs.getString(2); Timestamp timestamp = rs.getTimestamp(3); UserDynamicSuffix userDynamicSuffix = new UserDynamicSuffix(); userDynamicSuffix.setId(id); userDynamicSuffix.setDynamicSuffix(dynamicSuffix); userDynamicSuffix.setDateTime(new java.util.Date(timestamp.getTime())); userDynamicSuffix.setUserName(userName); userDynamicSuffixes.add(userDynamicSuffix); } } catch (SQLException e) { LOG.error("", e); } finally { close(con, pst, rs); } return userDynamicSuffixes; }