It's different for each person. Your doctor will tell you how long you'll have to wear the cast.
Most people wear a cast for six to eight weeks.
Casts are usually made of plaster or fiberglass. Fiberglass casts shouldn't get wet, but if it does, it can be dried. If it gets wet, it may soften or crack and lose its proper position. Then, keep the area uncovered until it's completely dry. If your cast starts to smell bad, rub a little bit of dry baking soda into the soiled areas.