A man who brandished a hammer at another man in the street in front of children and their parents has been jailed for 18 months.