public String getInternalTimeString ( ColumnInformation columnInfo ) { if ( lastValueWasNull ( ) ) { return null ; } if ( length == 0 ) { // binary send 00:00:00 as 0. if ( columnInfo . getDecimals ( ) == 0 ) { return "00:00:00" ; } else { StringBuilder value = new StringBuilder ( "00:00:00." ) ; int decimal = columnInfo . getDecimals ( ) ; while ( decimal -- > 0 ) { value . append ( "0" ) ; } return value . toString ( ) ; } } String rawValue = new String ( buf , pos , length , StandardCharsets . UTF_8 ) ; if ( "0000-00-00" . equals ( rawValue ) ) { return null ; } int day = ( ( buf [ pos + 1 ] & 0xff ) | ( ( buf [ pos + 2 ] & 0xff ) << 8 ) | ( ( buf [ pos + 3 ] & 0xff ) << 16 ) | ( ( buf [ pos + 4 ] & 0xff ) << 24 ) ) ; int hour = buf [ pos + 5 ] ; int timeHour = hour + day * 24 ; String hourString ; if ( timeHour < 10 ) { hourString = "0" + timeHour ; } else { hourString = Integer . toString ( timeHour ) ; } String minuteString ; int minutes = buf [ pos + 6 ] ; if ( minutes < 10 ) { minuteString = "0" + minutes ; } else { minuteString = Integer . toString ( minutes ) ; } String secondString ; int seconds = buf [ pos + 7 ] ; if ( seconds < 10 ) { secondString = "0" + seconds ; } else { secondString = Integer . toString ( seconds ) ; } int microseconds = 0 ; if ( length > 8 ) { microseconds = ( ( buf [ pos + 8 ] & 0xff ) | ( buf [ pos + 9 ] & 0xff ) << 8 | ( buf [ pos + 10 ] & 0xff ) << 16 | ( buf [ pos + 11 ] & 0xff ) << 24 ) ; } StringBuilder microsecondString = new StringBuilder ( Integer . toString ( microseconds ) ) ; while ( microsecondString . length ( ) < 6 ) { microsecondString . insert ( 0 , "0" ) ; } boolean negative = ( buf [ pos ] == 0x01 ) ; return ( negative ? "-" : "" ) + ( hourString + ":" + minuteString + ":" + secondString + "." + microsecondString ) ; }
Get Time in string format from raw binary format .