If you're on a boomer sub (missiles), there are 2 crews, so you are only on the boat 1/2 of the year and of that portion only at sea like 2/3 of the time. The rest you're in classes/schools/R&R/etc. At least that's how it was back in my time. So in a year, I might have been actually at sea for 3-4 months, with 1-2 months of R&R (you just report in twice/week) then schools/training/etc the rest of the time.
Fast attack subs are a different story, but you still have a lot of downtime.
My best time was decommissioning my first sub, in Hawaii. It was in drydock for 9 months, I had duty every 3rd or 4th day (have to be 'at work' 24 hours) and worked regular days during the week the rest of the time. That was tough, let me tell you!!! hehe