public LocalTime getInternalLocalTime ( ColumnInformation columnInfo , TimeZone timeZone ) throws SQLException { if ( lastValueWasNull ( ) ) { return null ; } if ( length == 0 ) { lastValueNull |= BIT_LAST_FIELD_NULL ; return null ; } switch ( columnInfo . getColumnType ( ) . getSqlType ( ) ) { case Types . TIME : int day = 0 ; int hour = 0 ; int minutes = 0 ; int seconds = 0 ; int microseconds = 0 ; final boolean negate = ( buf [ pos ] & 0xff ) == 0x01 ; if ( length > 4 ) { day = ( ( buf [ pos + 1 ] & 0xff ) + ( ( buf [ pos + 2 ] & 0xff ) << 8 ) + ( ( buf [ pos + 3 ] & 0xff ) << 16 ) + ( ( buf [ pos + 4 ] & 0xff ) << 24 ) ) ; } if ( length > 7 ) { hour = buf [ pos + 5 ] ; minutes = buf [ pos + 6 ] ; seconds = buf [ pos + 7 ] ; } if ( length > 8 ) { microseconds = ( ( buf [ pos + 8 ] & 0xff ) + ( ( buf [ pos + 9 ] & 0xff ) << 8 ) + ( ( buf [ pos + 10 ] & 0xff ) << 16 ) + ( ( buf [ pos + 11 ] & 0xff ) << 24 ) ) ; } return LocalTime . of ( ( negate ? - 1 : 1 ) * ( day * 24 + hour ) , minutes , seconds , microseconds * 1000 ) ; case Types . VARCHAR : case Types . LONGVARCHAR : case Types . CHAR : //string conversion String raw = new String ( buf , pos , length , StandardCharsets . UTF_8 ) ; try { return LocalTime . parse ( raw , DateTimeFormatter . ISO_LOCAL_TIME . withZone ( timeZone . toZoneId ( ) ) ) ; } catch ( DateTimeParseException dateParserEx ) { throw new SQLException ( raw + " cannot be parse as LocalTime (format is \"HH:mm:ss[.S]\" for data type \"" + columnInfo . getColumnType ( ) + "\")" ) ; } case Types . TIMESTAMP : ZonedDateTime zonedDateTime = getInternalZonedDateTime ( columnInfo , LocalTime . class , timeZone ) ; return zonedDateTime == null ? null : zonedDateTime . withZoneSameInstant ( ZoneId . systemDefault ( ) ) . toLocalTime ( ) ; default : throw new SQLException ( "Cannot read LocalTime using a " + columnInfo . getColumnType ( ) . getJavaTypeName ( ) + " field" ) ; } }
Get LocalTime from raw binary format .