Skip to content

Instantly share code, notes, and snippets.

@dai0304
Created January 11, 2012 02:34
Show Gist options
  • Save dai0304/1592633 to your computer and use it in GitHub Desktop.
Save dai0304/1592633 to your computer and use it in GitHub Desktop.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Time;
public class Main {
public static void main(String[] args) throws Exception {
Connection con = DriverManager.getConnection("jdbc:h2:mem:test");
Statement st1 = con.createStatement();
st1.execute("create table test (t time)");
st1.execute("insert into test values ('0:00:00')");
ResultSet rs1 = st1.executeQuery("select * from test");
rs1.next();
Time time = rs1.getTime("t");
System.out.println(time.getTime()); // -32400000
System.out.println(time.equals(new Time(0L))); // false
System.out.println(time.equals(new Time(-32400000L))); // true
System.out.println(time.equals(Time.valueOf("0:00:00"))); // true
st1.close();
con.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment