Jayden Williams has been spared imprisonment so he can receive help for anger management after two outbursts in less than four months.
About 4.30pm on September 30, Williams was walking along Dublin St with his sister when he became angry about his partner cheating on him and started kicking in a power transformer.
Police were called and found a knife on Williams, which he told them he needed because he had recently been jumped.
His lawyer, Stephen Ross, told the Whanganui District Court on Tuesday that Williams was living in a tent when Mr Ross was first assigned to help him.
However, the 23-year-old had spent the past 31/2 weeks in prison.
That is because at the time of his latest offending, Williams was on bail to be sentenced for wilful damage and burglary after an incident in June where he stole items from his former flat and urinated on a bed before leaving the property.
He has also pleaded guilty to possession of an offensive weapon and disorderly behaviour.
Judge Philip Crayton said it was in the interests of the community that Williams was handed a sentence that would allow him to address his anger issues.
"So that when you get into that situation again, you don't deal with it in a way that the police get called and you get arrested."
Williams was sentenced to six months of community detention, 120 hours of community work and 12 months' supervision.