You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having an issue with getTimestamp() and time zones. The following test fails because the actual result is offset to my local time. Prefixing the SQL query with SET TIME ZONE 'UTC' has no effect.
package com.github.ryanholdren.example;
import com.github.pgasync.ConnectionPool;
import com.github.pgasync.ConnectionPoolBuilder;
import com.opentable.db.postgres.embedded.EmbeddedPostgres;
import static com.opentable.db.postgres.embedded.EmbeddedPostgres.start;
import java.io.IOException;
import java.time.Instant;
import static java.time.Instant.parse;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.postgresql.ds.PGSimpleDataSource;
public class TimeZoneTest {
private static final String SQL = "SELECT TIMESTAMP WITH TIME ZONE '2004-10-19T10:23:54Z' AS output;";
private static final Instant EXPECTED = parse("2004-10-19T10:23:54Z");
@Test
public void test() throws IOException {
try (final EmbeddedPostgres postgres = start()) {
final PGSimpleDataSource database = (PGSimpleDataSource) postgres.getPostgresDatabase();
final ConnectionPool pool = new ConnectionPoolBuilder()
.hostname("localhost")
.port(postgres.getPort())
.database(database.getDatabaseName())
.username(database.getUser())
.password(database.getPassword())
.build();
final Instant actual = pool.queryRows(SQL).map(row -> {
return row.getTimestamp(0).toInstant();
}).toBlocking().first();
assertEquals(EXPECTED, actual);
}
}
}
I am having an issue with
getTimestamp()
and time zones. The following test fails because the actual result is offset to my local time. Prefixing the SQL query withSET TIME ZONE 'UTC'
has no effect.Here is the Maven project: TimeZoneTest.zip
The text was updated successfully, but these errors were encountered: