For design patents the answer is easy, design patents now have a term of 15 years from issuance although until recently, the term was 14 years from issuance.
For utility patents filed after June 8, 1995, the basic rule is that a patent can last 20 years from the filing date of a non-provisional application. The rule gets more complicated in that a patent application can claim priority to an earlier filed non-provisional application. In such a situation, the patent can last 20 years from the filing date of the earliest non-provisional application claimed as a priority application.
The patent term can end early from a failure to pay a maintenance fee to keep the patent alive. There are three required maintenance fees. If these fees are not paid by the 4th, 8th, and 12th anniversary of the issuance of a patent, then the patent lapses. The patent can be revived if the failure to pay the maintenance fee was not intentional.
Another complication is that the patent term can be extended beyond the 20 year rule if the government slowed down the process. The adjustment to the expiration date is called Patent Term Adjustment (PTA). There is a complicated system that adds PTA days if the government is slower than mandated for certain milestones but then retracts bonus days when the applicant causes delays. The days of patent term adjustment are printed on the front page of the issued patent.
There are a number of other less common adjustments to the term of a patent.