I'm a former English teacher, so I'll try this. There are a couple of ways you could say this. (Use numerals for numbers larger than ten.)
1. "I was in jail 21 years and 363 days." (It's correct, but it's not preferable.)
2. "I was in jail nearly 22 years." (This is preferable because it's more succinct.)
3. "I spent nearly 22 years in jail." (See #2.)
4. "I spent 22 years, minus two days, in jail." (This would get the point across that the person was in jail only slightly less than 22 years, if that matters.)
Hope that helps.
Student or Learner