For time we can use millis() or frameCount:
If you pick frameCount, remember that draw() is called back around 60 FPS.
So, if you wish for your fish to turn around between 5 to 10 seconds you could use this:
nextFrameChange = frameCount + (int) random(5 * 60, 10 * 60);
Then keep polling the value of frameCount until it reaches nextFrameChange:
if (frameCount >= nextFrameChange) swapDirection();