public static long plus(long tstamp,long microseconds){
  long microsmask=(long)UMASK;
  long newmicros=tstamp & microsmask;
  if ((newmicros + microseconds) <= MAX_MICROS) {
    tstamp+=microseconds;
  }
 else {
    int[] pieces=new int[NUMIDX];
    ComponentTime.unpackBits(tstamp,pieces);
    int year=pieces[YIDX];
    int month=pieces[MIDX];
    int day=pieces[DIDX];
    int hour=pieces[HIDX];
    int minute=pieces[IIDX];
    int second=pieces[SIDX];
    newmicros+=microseconds;
    int overseconds=(int)(newmicros / 1000000L);
    newmicros=(newmicros % 1000000L);
    GregorianCalendar cal=new GregorianCalendar(year,month - 1,day,hour,minute,second);
    cal.add(Calendar.SECOND,overseconds);
    second=cal.get(Calendar.SECOND);
    minute=cal.get(Calendar.MINUTE);
    hour=cal.get(Calendar.HOUR_OF_DAY);
    day=cal.get(Calendar.DAY_OF_MONTH);
    month=cal.get(Calendar.MONTH) + 1;
    year=cal.get(Calendar.YEAR);
    tstamp=newmicros;
    tstamp|=((long)year) << YPOS;
    tstamp|=((long)month) << MPOS;
    tstamp|=((long)day) << DPOS;
    tstamp|=((long)hour) << HPOS;
    tstamp|=((long)minute) << IPOS;
    tstamp|=((long)second) << SPOS;
  }
  return (tstamp);
}

public static long plus ( long tstamp , long microseconds ) { long microsmask = ( long ) UMASK ; long newmicros = tstamp & microsmask ; if ( ( newmicros + microseconds ) <= MAX_MICROS ) { tstamp += microseconds ; } else { int [ ] pieces = new int [ NUMIDX ] ; ComponentTime . unpackBits ( tstamp , pieces ) ; int year = pieces [ YIDX ] ; int month = pieces [ MIDX ] ; int day = pieces [ DIDX ] ; int hour = pieces [ HIDX ] ; int minute = pieces [ IIDX ] ; int second = pieces [ SIDX ] ; newmicros += microseconds ; int overseconds = ( int ) ( newmicros / 1000000L ) ; newmicros = ( newmicros % 1000000L ) ; GregorianCalendar cal = new GregorianCalendar ( year , month - 1 , day , hour , minute , second ) ; cal . add ( Calendar . SECOND , overseconds ) ; second = cal . get ( Calendar . SECOND ) ; minute = cal . get ( Calendar . MINUTE ) ; hour = cal . get ( Calendar . HOUR_OF_DAY ) ; day = cal . get ( Calendar . DAY_OF_MONTH ) ; month = cal . get ( Calendar . MONTH ) + 1 ; year = cal . get ( Calendar . YEAR ) ; tstamp = newmicros ; tstamp |= ( ( long ) year ) << YPOS ; tstamp |= ( ( long ) month ) << MPOS ; tstamp |= ( ( long ) day ) << DPOS ; tstamp |= ( ( long ) hour ) << HPOS ; tstamp |= ( ( long ) minute ) << IPOS ; tstamp |= ( ( long ) second ) << SPOS ; } return ( tstamp ) ; }
increment a component timestamp by a specifed number of microseconds ( must be less than one full second )
