public OffsetTime getInternalOffsetTime ( ColumnInformation columnInfo , TimeZone timeZone ) throws SQLException { if ( lastValueWasNull ( ) ) { return null ; } if ( length == 0 ) { lastValueNull |= BIT_LAST_FIELD_NULL ; return null ; } ZoneId zoneId = timeZone . toZoneId ( ) . normalized ( ) ; if ( zoneId instanceof ZoneOffset ) { ZoneOffset zoneOffset = ( ZoneOffset ) zoneId ; String raw = new String ( buf , pos , length , StandardCharsets . UTF_8 ) ; switch ( columnInfo . getColumnType ( ) . getSqlType ( ) ) { case Types . TIMESTAMP : if ( raw . startsWith ( "0000-00-00 00:00:00" ) ) { return null ; } try { return ZonedDateTime . parse ( raw , TEXT_LOCAL_DATE_TIME . withZone ( zoneOffset ) ) . toOffsetDateTime ( ) . toOffsetTime ( ) ; } catch ( DateTimeParseException dateParserEx ) { throw new SQLException ( raw + " cannot be parse as OffsetTime. time must have \"yyyy-MM-dd HH:mm:ss[.S]\" format" ) ; } case Types . TIME : try { LocalTime localTime = LocalTime . parse ( raw , DateTimeFormatter . ISO_LOCAL_TIME . withZone ( zoneOffset ) ) ; return OffsetTime . of ( localTime , zoneOffset ) ; } catch ( DateTimeParseException dateParserEx ) { throw new SQLException ( raw + " cannot be parse as OffsetTime (format is \"HH:mm:ss[.S]\" for data type \"" + columnInfo . getColumnType ( ) + "\")" ) ; } case Types . VARCHAR : case Types . LONGVARCHAR : case Types . CHAR : try { return OffsetTime . parse ( raw , DateTimeFormatter . ISO_OFFSET_TIME ) ; } catch ( DateTimeParseException dateParserEx ) { throw new SQLException ( raw + " cannot be parse as OffsetTime (format is \"HH:mm:ss[.S]\" with offset for data type \"" + columnInfo . getColumnType ( ) + "\")" ) ; } default : throw new SQLException ( "Cannot read " + OffsetTime . class . getName ( ) + " using a " + columnInfo . getColumnType ( ) . getJavaTypeName ( ) + " field" ) ; } } if ( options . useLegacyDatetimeCode ) { //system timezone is not an offset throw new SQLException ( "Cannot return an OffsetTime for a TIME field when default timezone is '" + zoneId + "' (only possible for time-zone offset from Greenwich/UTC, such as +02:00)" ) ; } //server timezone is not an offset throw new SQLException ( "Cannot return an OffsetTime for a TIME field when server timezone '" + zoneId + "' (only possible for time-zone offset from Greenwich/UTC, such as +02:00)" ) ; }
Get OffsetTime format from raw text format .