code: public static int enc_time( Date date, byte[] dst, int di, int enc )
      {
          long t;
  
          switch( enc ) {
              case TIME_1970_SEC_32BE:
                  return enc_uint32be( (int)(date.getTime() / 1000L), dst, di );
              case TIME_1970_SEC_32LE:
                  return enc_uint32le( (int)(date.getTime() / 1000L), dst, di );
              case TIME_1904_SEC_32BE:
                  return enc_uint32be( (int)((date.getTime() / 1000L +
                      SEC_BETWEEEN_1904_AND_1970) & 0xFFFFFFFF), dst, di );
              case TIME_1904_SEC_32LE:
                  return enc_uint32le( (int)((date.getTime() / 1000L +
                      SEC_BETWEEEN_1904_AND_1970) & 0xFFFFFFFF), dst, di );
              case TIME_1601_NANOS_64BE:
                  t = (date.getTime() + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L;
                  return enc_uint64be( t, dst, di );
              case TIME_1601_NANOS_64LE:
                  t = (date.getTime() + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L;
                  return enc_uint64le( t, dst, di );
              case TIME_1970_MILLIS_64BE:
                  return enc_uint64be( date.getTime(), dst, di );
              case TIME_1970_MILLIS_64LE:
                  return enc_uint64le( date.getTime(), dst, di );
              default:
                  throw new IllegalArgumentException( "Unsupported time encoding" );
          }
      }
docs: /* Encode times