Re: timestamps and java epochs
От | Thomas O'Dowd |
---|---|
Тема | Re: timestamps and java epochs |
Дата | |
Msg-id | 20010825110537.O20830@beast.uwillsee.com обсуждение исходный текст |
Ответ на | timestamps and java epochs (Laurette Cisneros <laurette@nextbus.com>) |
Список | pgsql-jdbc |
Sounds like a general pgsql question rather than a jdbc one... For jdbc it doesn't matter, you just call ResultSet.getTimestamp() on the field value. To get epoch time, you can just call getTime() on the timestamp. ie. ResultSet rs = stmt.executeQuery("SELECT t1, t2 FROM xxxx"); Timestamp t1 = rs.getTimestamp(1); Timestamp t2 = rs.getTimestamp(2); long e1 = t1.getTime(); long e2 = t2.getTime(); Inside pgsql if you want epoch, just use... SELECT EXTRACT(EPOCH FROM t1) FROM xxxx; Tom. On Fri, Aug 24, 2001 at 12:23:33PM -0700, Laurette Cisneros wrote: > > I have a table in which there are two fields that are timestamps. > > How do I parse these values back into epoch times? The > docs say that the values may come back in one of four formats, > how do I know which one I'll get? I can't seem to get JDBC to > take the "set datestyle" command (it throws an SQLException). > > Even better: is there a database function I can use to turn these > things into a unix epoch time? > > Thanks, > > Laurette > Nextbus, Inc. > www.nextbus.com > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Thomas O'Dowd. - Nooping - http://nooper.com tom@nooper.com - Testing - http://nooper.co.jp/labs
В списке pgsql-jdbc по дате отправления: