A man who headbutted a former schoolfriend and threatened to kill him with a hammer has received a suspended jail sentence.