The court may, on the conviction of any person for an offense against the person or property of another and when necessary for the public good, require the defendant to enter into an undertaking, with sufficient sureties, to keep the peace for a period not exceeding 12 months and, on his failure to do so, may commit him.
Ala. Code § 15-6-60 (1975)