use of java.sql.Timestamp in project querydsl by querydsl.
the class JSR310InstantTypeTest method set.
@Test
public void set() throws SQLException {
Instant value = Instant.now();
Timestamp ts = new Timestamp(value.toEpochMilli());
PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
stmt.setTimestamp(1, ts, UTC);
EasyMock.replay(stmt);
type.setValue(stmt, 1, value);
EasyMock.verify(stmt);
}
use of java.sql.Timestamp in project querydsl by querydsl.
the class JSR310InstantTypeTest method jodaSet.
@Test
public void jodaSet() throws SQLException {
Instant value = Instant.now();
Timestamp ts = new Timestamp(value.toEpochMilli());
PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
stmt.setTimestamp(1, ts);
EasyMock.replay(stmt);
new DateTimeType().setValue(stmt, 1, toJoda(value));
EasyMock.verify(stmt);
}
use of java.sql.Timestamp in project querydsl by querydsl.
the class JSR310OffsetDateTimeTypeTest method get.
@Test
public void get() throws SQLException {
ResultSet resultSet = EasyMock.createNiceMock(ResultSet.class);
EasyMock.expect(resultSet.getTimestamp(1, UTC)).andReturn(new Timestamp(UTC.getTimeInMillis()));
EasyMock.replay(resultSet);
OffsetDateTime result = type.getValue(resultSet, 1);
EasyMock.verify(resultSet);
assertNotNull(result);
assertTrue(result.toEpochSecond() == 0);
}
use of java.sql.Timestamp in project querydsl by querydsl.
the class JSR310ZonedDateTimeTypeTest method set.
@Test
public void set() throws SQLException {
ZonedDateTime value = ZonedDateTime.now();
Timestamp ts = new Timestamp(value.toInstant().toEpochMilli());
PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
stmt.setTimestamp(1, ts, UTC);
EasyMock.replay(stmt);
type.setValue(stmt, 1, value);
EasyMock.verify(stmt);
}
use of java.sql.Timestamp in project jforum2 by rafaelsteil.
the class GenericForumDAO method checkUnreadTopics.
/**
* @see net.jforum.dao.ForumDAO#hasUnreadTopics(int, long)
*/
public List checkUnreadTopics(int forumId, long lastVisit) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.checkUnreadTopics"));
p.setInt(1, forumId);
p.setTimestamp(2, new Timestamp(lastVisit));
rs = p.executeQuery();
while (rs.next()) {
Topic t = new Topic();
t.setId(rs.getInt("topic_id"));
t.setTime(new Date(rs.getTimestamp(1).getTime()));
l.add(t);
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations