public synchronized Timestamp toTimestamp ( Calendar cal , String s ) throws SQLException { if ( s == null ) { return null ; } int slen = s . length ( ) ; // convert postgres's infinity values to internal infinity magic value if ( slen == 8 && s . equals ( "infinity" ) ) { return new Timestamp ( PGStatement . DATE_POSITIVE_INFINITY ) ; } if ( slen == 9 && s . equals ( "-infinity" ) ) { return new Timestamp ( PGStatement . DATE_NEGATIVE_INFINITY ) ; } ParsedTimestamp ts = parseBackendTimestamp ( s ) ; Calendar useCal = ts . tz != null ? ts . tz : setupCalendar ( cal ) ; useCal . set ( Calendar . ERA , ts . era ) ; useCal . set ( Calendar . YEAR , ts . year ) ; useCal . set ( Calendar . MONTH , ts . month - 1 ) ; useCal . set ( Calendar . DAY_OF_MONTH , ts . day ) ; useCal . set ( Calendar . HOUR_OF_DAY , ts . hour ) ; useCal . set ( Calendar . MINUTE , ts . minute ) ; useCal . set ( Calendar . SECOND , ts . second ) ; useCal . set ( Calendar . MILLISECOND , 0 ) ; Timestamp result = new Timestamp ( useCal . getTimeInMillis ( ) ) ; result . setNanos ( ts . nanos ) ; return result ; }
Parse a string and return a timestamp representing its value .