It is pretty clear that today the US military is an all volunteer force and it is not allowed to take people who are joining to avoid going to prison. Was there ever a time when a judge could sentence a criminal to prison or military service? If so, how did it work? Was it for a fixed time and what happens if the criminal was found not fit for duty and separated from the military?
Over the years I've read many accounts where people stated that they were told by a judge that they could spend X months in jail or they could join up. This could never hold up as a law in any state, but is more of an informal use of a judge's discretion. It's probably a lot less common today with today's very professional military. A simple Google search turned up only this one case on the first page of results: https://www.stripes.com/news/judge-said-army-or-jail-but-military-doesn-t-want-him-1.44417
This was much more possible during World War II when America needed "every man." Some years ago, I knew a man (born in 1925) who was arrested for "carjacking" who was sentenced to two years, with sentence to be suspended if he would volunteer for two years in the Army (and they would accept him.) That, in fact, did happen.
The judge probably figured that the rehabilitative impact of the one would be as great as the other, but the Army offered the more productive outlet for both the convict and for society.
My father punched one of his high school teachers. Justifiably, IMO, based on the story as he told it.
This occurred a few years before the end of the Korean "conflict". He was given the choice that day to go with the police or go with his parents (he was under 18) to an Army recruiting office.
It's not as easy to join the military these days so this tactic is no longer viable. A modern analog would be the courts sending people to AA meetings in return for a lighter penalty - they can't force anyone to go so they manipulate them into it.
Jimmy Hendrix was given the choice of prison or military service. Wikipedia his name.
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.