Does PGInterval class handle iso_8601 intervalstyle?
От | Adam Mackler |
---|---|
Тема | Does PGInterval class handle iso_8601 intervalstyle? |
Дата | |
Msg-id | 20150326231231.GG42707@scruffle.mackler.org обсуждение исходный текст |
Ответы |
Re: Does PGInterval class handle iso_8601 intervalstyle?
|
Список | pgsql-jdbc |
Hi: I'm using server version 9.4.1 and JDBC driver version 9.4-1201-jdbc41. When I have my server's output format of the interval type (intervalstyle) set to iso_8601, I get values such as: "PT2H5M25.562249S" which when passed to the PGInterval constructor: new PGInterval("PT2H5M25.562249S") yields a org.postgresql.util.PGInterval = 0 years 0 mons 0 days 0 hours 0 mins 0.00 secs Clearly incorrect. I get the same result for the example of iso_8601 "Day-Time Interval" format given in section 8.5.5 of the manual: "P3DT4H5M6S". http://www.postgresql.org/docs/9.4/interactive/datatype-datetime.html#DATATYPE-INTERVAL-OUTPUT The comments on lines 119-120 of the PGInterval class' source code file suggest that this format should be parsed: > This handles hours, minutes, seconds and microseconds for ISO intervals https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/util/PGInterval.java#L119 Moreover, the javadoc for the setValue() method (used by the constructor) claims that an "SQLException Is thrown if the string representation has an unknown format," suggesting that if the given format cannot be parsed it ought to raise an exception rather than returning the wrong value. https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/util/PGInterval.java#L79 Is is possible to use the PGInterval class to parse interval literals in the format that a server with intervalstyle set to iso_8601 produces? If so, how? If not, why not, and why is no exception raised when trying to do so? Thanks very much, -- Adam Mackler
В списке pgsql-jdbc по дате отправления: