Hard water only makes it more difficult to maintain whites. The chemical present in the water reacts with the detergent and ends up fading the white to yellow.
Add 1/4th cup of bleach in half a bucket of warm water. Soak your whites in it for 10 minutes. Always wear rubber gloves while dealing with bleach. Rinse, wash and repeat if necessary.
Add 1 cup of ammonia and 1 cup Vim dishwash liquid in a bucket and mix it with a toothbrush. Soak the stained portion in it for 30 minutes. Scrub the garment with the same toothbrush and rinse it in water.
Add 1 part of water and 1 part of Hydrogen peroxide (depending on the size of the garment). Soak the garment in it for 30 minutes and then rinse it. Rewash and repeat if needed.