A really, really long time. If it is stored correctly, almost indefinitely. How can you do that though? Ammunition is one of those things that it’s hard to have too much of. Sure, it’s possible to be weighed down by it when you are hiking through the wilderness on a hunt, but it’s often better to have too much than too little. That is especially true for long-term storage. If you found a great deal and bought as much as you could, or are gearing up for that zombie apocalypse, it’s good to have a safe place to store all that ammo. 
     Fortunately, ammunition is pretty sturdy. Modern cartridges are watertight, metal containers, surrounding mostly minerals, it makes sense that they should be so sturdy. Perhaps it’s not so surprising that it can still be safe to shoot pre-WWII ammo. Good quality, modern ammunition should keep just as well if not better. When it comes to storing ammo for future use, you are only limited by the space in which you can safely store it. To determine what that space is you will need to consider what conditions are ideal for the long-term storage of ammunition. 
     It may be common sense, but a clean, dry, cool, and stable place, while in a proper container, is the best way to keep your ammunition in good condition. Here's why:

- Clean - Important because you want your ammunition to be clean. That unwanted stuff that can get on your ammunition may contribute to corrosion and misfires. Dirty, greasy, or oily ammunition could cause a misfire. If the oil on your ammunition is flammable it could cause more combustion than you were hoping for, possibly leading to a dangerous situation. So clean storage leads to clean ammunition, just what you want. 

- Dry - This is very important, probably THE most important factor, as dampness and wetness can cause corrosion to the casing. Corrosion can lead to all sorts of malfunctions and losing the use of that valuable ammunition. Don’t store your ammo in saltwater, it is one of the worst places where you could store ammunition because the salt AND the water are corrosive. 

- Cool - This is important though maybe not why you might think. Cool air helps things stay dry. All other factors being equal, the colder the air, the less moisture in the air. Less moisture means less corrosion. The idea that you shouldn’t store your ammo in a hot area is not so much for fear that it will go off on its own. There is an idea that if it gets too hot your ammunition will explode. This is somewhat true, though it might not be as bad as you may think. First of all, the temperatures needed to affect ammunition are usually only achieved if there is a fire, or if not open flame then at least oven temperatures. At a few hundred degrees Fahrenheit the primer might pop. Though this is potentially dangerous and will make your ammunition unusable, it is not the same as if it was fired from a gun. Without the pressure from the gun chamber, the bullets are discharged at a fraction of the velocity, and while still dangerous, it is not the same as a number of guns going off. At a thousand degrees the lead in the bullet will melt, but the chances that the cartridge was still usable at say 900° degrees is pretty slim. 

- Stable - A stable temperature as well as a stable place. A cool and stable temperature, anywhere around room temperature and cooler, is ideal. Fluctuating temperatures can lead to condensation, which leads to corrosion. The way this works is if the air got warm, then moisture could naturally enter that air, then as it cooled again the moisture would get squeezed out of the air and deposit itself onto the ammunition in the form of condensation. For a stable place look for somewhere that your ammunition is not likely to go tumbling or have things tumbling onto it. 

- Proper Container - When considering storage containers, ammo boxes may seem like the obvious choice, and for good reason, they’ve worked well for many years. Your storage container should be of tough material, painted lightweight steel is very sturdy though there are plenty of plastic containers that work as well. They should be waterproof and sealable, to keep all of that corrosive moisture out. It should have a sturdy latch to keep it locked tight. There are other factors you may want to consider like stackability, versatility (useful for other things), and additional holes and features for locks or tie-downs. It’s up to you which containers will work best for you. Generally, if you can store food in it, then you can store ammunition in it. If you have any spare silica packs from other packaged items, you may want to throw them in there as well as they will help with moisture. 

     Fortunately, modern ammo is very safe. If it is stored properly it should last beyond your lifetime. To be completely safe you should not shoot ammo unless you know its history. Inspect each cartridge before use to ensure there are no dents, cracks, corrosion, or other types of imperfections. You might be able to get away with shooting a dented cartridge, but why would you try?