A Connecticut man who was assaulted by three juveniles while at work has been sentenced to prison for stabbing one of the attackers.

The Connecticut Post reports 21-year-old Jeffrey Sumpter of Bridgeport received 18 months in jail Monday at a Stamford courthouse.

The paper reported that Sumpter — who was convicted of felony first-degree assault — also will have to spend three years following his release on probation. If he breaks the law during that time, Sumpter could be made to serve all or part of a 42-month prison sentence.

Sumpter was working at a Dunkin’ Donuts in Norwalk last October when he was jumped by three males. During the assault, Sumpter stabbed one of them in the leg.

“I was defending myself,” Sumpter said during the hearing.

Judge John Blawie told Sumpter that he believed his version of events, but had to follow the letter of the law.

Under Connecticut law, assault victims cannot use deadly force if they are able to retreat from their attackers. By contrast, 27 states — most notably Florida — have passed so-called “stand-your-ground” laws, which entitle citizens to use force in self-defense if there is a reasonable belief of a threat.

The Associated Press contributed to this report.