YORK, Pa. — A man who was a teenager at the time of the Pennsylvania murder of a law student for which he was sentenced to life in prison has been resentenced to 30 years to life.

Jordan Wallick, now 21, was 15 when York County authorities said he shot and killed James Wallmuth III, 28, a law student and former intern in the district attorney’s office, outside a bar during a botched July 2010 robbery.

Wallick was convicted of second-degree murder and sentenced to life plus 15 to 30 years. But an appeals court ordered a new sentencing hearing, citing a U.S. Supreme Court ruling banning mandatory life terms for juveniles.

Judge Michael Bortner said Friday before imposing sentence that a presentence report painted a picture of a “young man who has not had an easy time in life,” but he said “that is not an excuse for the crime that was committed.”

Prosecutors argued for a term of 40 years to life and defense attorneys sought a 30- to 60-year term. At a hearing in August, Wallick read a letter of apology to the victim’s family, saying he wakes up each day hating himself for what he’s done.

“There isn’t anything I can do or say to bring your loved one back,” Wallick said, choking back tears. “I could apologize a million times and that wouldn’t change any of it.”

Authorities said Wallick, having recently become involved with a gang, was given a gun by some adults and told to rob Wallmuth of his cellphone, but he said when he did so the victim grabbed the gun and it went off accidentally.

Psychiatrists testifying for prosecution and defense said he had expressed remorse for the victim and his family as well as his own family, but the prosecution’s psychiatrist said he downplays his role in the murder, minimizing and rationalizing his actions.

Defense attorneys said their client will now be eligible for parole in 2040.

The judge said that Wallick’s behavior during incarceration displayed disobedience and violence until a year and a half ago, when he appeared to choose a different course. Since then, he has become a certified peer support specialist who helps other inmates and also is participating in a program where inmates train service dogs.

But Bortner said he imposed life as the maximum term “because we feel we don’t know where Jordan is heading at this time.” He also referred to the defendant’s letter of apology.

“I’ve looked at that letter numerous times,” he said. “I hope I can believe it.”