I have MonetDB database with table containing user table:
CREATE TABLE user
(
birth_date TIMESTAMP NOT NULL
);
birth_date
is saved in GMT without DST. (This is the default behavior of MonetDB). So I should change the TimeZone
in my application. Here is my code:
Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
Connection con = DriverManager.getConnection("jdbc:monetdb://localhost/online", "monetdb", "monetdb");
Statement st = con.createStatement();
ResultSet rs;
rs = st.executeQuery("SELECT * FROM user");
while (rs.next()) {
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tehran"));
c.setTime(rs.getTimestamp("birth_date"));
System.out.println(c.get(Calendar.YEAR) + "-" + c.get(Calendar.MONTH) + "-" + c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND));
}
But this code print the same TIMESTAMP
in the database. Is this the wrong way to convert TimeZone
? I'm using MonetDB version 11.9.5-20120516 on Debian 6 with openjdk 6. Here is the monetdbd getall /home/dbfarm
:
dbfarm /home/dbfarm/
status monetdbd[4187] 1.6 (Apr2012-SP1) is serving this dbfarm
mserver /usr/bin/mserver5
logfile /home/dbfarm//merovingian.log
pidfile /home/dbfarm//merovingian.pid
sockdir /tmp
port 50000
exittimeout 60
forward proxy
discovery yes
discoveryttl 600
control yes
passphrase {SHA512}ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346ec8c17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413
mapisock /tmp/.s.monetdb.50000
controlsock /tmp/.s.merovingian.50000