public void testTimezoneLess()

in phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/QueryServerBasicsIT.java [360:387]


  public void testTimezoneLess() throws Exception {

    try (Connection conn = DriverManager.getConnection(CONN_STRING);
         Statement stmt = conn.createStatement();
    ) {
      final String tableName = generateUniqueName();

      stmt.execute(
          "CREATE TABLE " + tableName + " (k VARCHAR NOT NULL PRIMARY KEY, i TIMESTAMP)");
      conn.commit();

      LocalDateTime now = LocalDateTime.now();
      //Avatica has only millisecond timestamps
      now = now.withNano((now.getNano()/1000000)*1000000);
      try(PreparedStatement upsert = conn.prepareStatement(
          "UPSERT INTO " + tableName + " VALUES (?, ?)")
      ) {
        upsert.setString(1, "1");
        upsert.setTimestamp(2, java.sql.Timestamp.valueOf(now));
        upsert.executeUpdate();
        conn.commit();
        ResultSet rs = stmt.executeQuery("select * from " + tableName);
        assertTrue(rs.next());
        LocalDateTime fromDB = rs.getTimestamp("i").toLocalDateTime();
        assertTrue("Timestamps do not match. inserted:" + now.toString() + " returned:" + fromDB.toString(), fromDB.compareTo(now) == 0);
      }
    }
  }