public LocalDateTime toLocalDateTime ( 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 LocalDateTime . MAX ; } if ( slen == 9 && s . equals ( "-infinity" ) ) { return LocalDateTime . MIN ; } ParsedTimestamp ts = parseBackendTimestamp ( s ) ; // intentionally ignore time zone // 2004-10-19 10:23:54+03:00 is 2004-10-19 10:23:54 locally LocalDateTime result = LocalDateTime . of ( ts . year , ts . month , ts . day , ts . hour , ts . minute , ts . second , ts . nanos ) ; if ( ts . era == GregorianCalendar . BC ) { return result . with ( ChronoField . ERA , IsoEra . BCE . getValue ( ) ) ; } else { return result ; } }
Parse a string and return a LocalDateTime representing its value .