Bug #651: Time difference of 30 in while reading in timestamp

Поиск
Список
Период
Сортировка
От pgsql-bugs@postgresql.org
Тема Bug #651: Time difference of 30 in while reading in timestamp
Дата
Msg-id 20020430140651.A374E475E29@postgresql.org
обсуждение исходный текст
Ответы Re: Bug #651: Time difference of 30 in while reading in timestamp  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Ravishankar Rajagopalan (rravishankar@sify.com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Time difference of 30 in while reading in timestamp

Long Description
I am using Java 1.3.1 and Postgres 7.1.2 and am writing timestamp without zone info to the database using JDBC (my zone
isIST or +5:30GMT). I find that there is always a time difference of 30 minutes when i read from the database. 

When i query the postgres database from the SQL prompt, the time is as i had written it. But when i read it from the
databaseinto my java code it is more exactly by 30 mins. 

I have pasted the code herewith (in which i have used a 30 min offset) . Any solution for this ?






Sample Code
 String databaseURL = "jdbc:postgresql:am";


    Timestamp ts_ls_dn =null, ts_current_time=null;
        long tld =0, tct=0, diff = 0, tot_fails=0;
        int rec_fails=0;
        boolean fatal_err = false;


try{
        Class.forName("org.postgresql.Driver");

        Connection conn1 = DriverManager.getConnection(databaseURL,"abc","");

        PreparedStatement p = conn1.prepareStatement("select  last_dn_time from mon where name=?");
        p.setInt(1, serv_id);

        ResultSet rs  = p.executeQuery();
        rs.next();
        ts_ls_dn = rs.getTimestamp("last_dn_time");

        ts_current_time = new Timestamp(System.currentTimeMillis());
        tld = ts_ls_dn.getTime();
        tct = ts_current_time.getTime();
        diff = ((tct-tld)/60000)+30;//Time in minutes. 30 added to makeup for error

    }
  catch (Exception x){
                   x.printStackTrace();
                   }


No file was uploaded with this report

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: LIKE Command
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bug #651: Time difference of 30 in while reading in timestamp