public Time getInternalTime ( ColumnInformation columnInfo , Calendar cal , TimeZone timeZone ) throws SQLException { if ( lastValueWasNull ( ) ) { return null ; } switch ( columnInfo . getColumnType ( ) ) { case TIMESTAMP : case DATETIME : Timestamp ts = getInternalTimestamp ( columnInfo , cal , timeZone ) ; return ( ts == null ) ? null : new Time ( ts . getTime ( ) ) ; case DATE : throw new SQLException ( "Cannot read Time using a Types.DATE field" ) ; default : Calendar calendar = Calendar . getInstance ( ) ; calendar . clear ( ) ; int day = 0 ; int hour = 0 ; int minutes = 0 ; int seconds = 0 ; boolean negate = false ; if ( length > 0 ) { 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 ] ; } calendar . set ( 1970 , Calendar . JANUARY , ( ( negate ? - 1 : 1 ) * day ) + 1 , ( negate ? - 1 : 1 ) * hour , minutes , seconds ) ; int nanoseconds = 0 ; if ( length > 8 ) { nanoseconds = ( ( buf [ pos + 8 ] & 0xff ) + ( ( buf [ pos + 9 ] & 0xff ) << 8 ) + ( ( buf [ pos + 10 ] & 0xff ) << 16 ) + ( ( buf [ pos + 11 ] & 0xff ) << 24 ) ) ; } calendar . set ( Calendar . MILLISECOND , nanoseconds / 1000 ) ; return new Time ( calendar . getTimeInMillis ( ) ) ; } }
Get time from raw binary format .