Franky Dymott, 50, of Main Street, appeared at Cardiff Magistrates’ Court charged with two offences.
Dymott was accused of possession of an offensive weapon in a public place, after he was alleged to have had a hammer on Pennsylvania in the Pentwyn area of Cardiff on March 1.
He was also accused of using threatening, abusive and insulting words or behaviour against a woman in Cardiff on that date with the intention of causing her harassment, alarm or distress.
Appearing in court on March 2, Dymott pleaded guilty to both offences.
The defendant was sentenced to an 18-month community order, and must complete 140 hours of unpaid work and 30 days of rehabilitation activity.
He was also ordered to pay ÂŁ85 in costs and a ÂŁ114 surcharge, and the victim was granted an 18-month restraining order.
