The defendant appeals from an order of a judge of the Superior Court denying his motion to correct a mittimus. See Mass.R.Crim.P. 42, 378 Mass. 919 (1979). He contends that the sentence he is presently serving should be shortened by (1) 185 days because of his attendance for that period in a drug and alcohol inpatient rehabilitation program imposed as a condition *29of his probation; and (2) five years because he has been improperly required to serve a portion of a prior sentence that had been vacated. We affirm the order denying the defendant’s motion.
1. Relevant facts and proceedings. Following his plea of guilty to a variety of charges on February 26, 1988, the defendant was sentenced to two and one-half years in a house of correction, committed, followed by a suspended eight- to ten-year sentence at the Massachusetts Correctional Institution at Cedar Junction (Cedar Junction), with a probationary period of five years. Subsequent to his release from the house of correction,1 the defendant, on December 15, 1989, was found in violation of the terms of his probation. The judge imposed a sentence of eight to ten years at Cedar Junction, five years to be served.2 However, the judge stayed the sentence until December 1, 1991, on certain probationary terms, one of which was that the defendant enter a long-term drug and alcohol program with an aftercare component. The length of treatment was to be determined by the facility.
Pursuant to the probationary requirement, the defendant entered the Steven Miller House, residing there from May 10, 1990, to November 12, 1990, and successfully completing the program. The probationary stay of approximately two years that was entered on December 15, 1989, expired without incident on December 1, 1991; on December 2, 1991, the judge vacated the five-year committed portion of the sentence, leaving the defendant with an eight- to ten-year suspended sentence, and imposed a new three-year period of probation.
On April 16, 1992, the defendant was found in violation of the most recently imposed probation requirements. Probation was revoked, and a portion of the eight- to ten-year suspended sentence was imposed. The defendant was ordered to serve *30three years of the eight- to ten-year sentence, with the balance suspended for three years. Following the filing by the defendant of a motion to revise and revoke, that sentence was altered to provide that committed time would be deemed served as of March 16, 1993. The balance of the eight- to ten-year term remained suspended, and the three-year probationary period was reinstated.
The defendant again violated probation, and the Superior Court ran out of patience. On April 6, 1994, a judge revoked the suspension and imposed the balance of the eight- to ten-year sentence. Subsequent motions by the defendant for reconsideration and for revision and revocation of the sentence were denied. Following an unsuccessful petition for a writ of habeas corpus, the defendant, on September 25, 2001, filed a motion to correct the mittimus, which was denied. The defendant’s appeal therefrom brings the case here.
2. The 185-day treatment period. The time the defendant spent at the Steven Miller House came to 185 days. Characterizing this residential treatment regimen as merely another form of incarceration, the defendant argues that the 185-day period should be treated as a period of service of a committed sentence, the result being that he should receive credit for 185 days when he was thereafter required to serve the balance of the eight- to ten-year sentence commencing April 6, 1994.3 We are not persuaded that attachment of the label “incarceration” takes into account the fundamental differences between service of a committed sentence and performance of a condition of probation.
At the outset, the defendant relies on the provisions of G. L. c. 127, § 129B, and G. L. c. 279, § 33A, as authority for his proposition that his stay at the Steven Miller House must be treated as service of a portion of a committed sentence. Those statutes apply to periods of confinement endured by defendants before and during trial, and prior to sentencing. They have no application to the present case.
The question then is whether there are other reasons why residency at an inpatient treatment facility undertaken in compli*31anee with a probation requirement should be treated as the equivalent of service of a portion of a committed sentence. A prisoner is entitled to credit for the time he has spent in prison. Commonwealth v. Boland, 43 Mass. App. Ct. 451, 454 (1997). “[Fjaimess is the appropriate measure in determining whether and to what extent” a defendant should be given credit for time spent in custody. Id., quoting from Chalifoux v. Commissioner of Correction, 375 Mass. 424, 427 (1978). On the other hand, there are distinctions between incarceration and probation, and it has been held generally “that a condition of probation is enforceable, even if it affects a ‘preferred’ right, where the condition is primarily designed to meet, i.e., ‘reasonably related’ to, the goals of sentencing and probation.” Commonwealth v. Power, 420 Mass. 410, 414 (1995), cert, denied, 516 U.S. 1042 (1996).
The requirement that the defendant submit to a residential treatment program was plainly within the authority of the judge to impose as a condition of probation. See G. L. c. 276, § 87A (such conditions “may include, but shall not be limited to, participation by said person in specified rehabilitative programs”). Given that rehabilitation and protection of the public are two of the recognized goals of sentencing, conditioning the defendant’s probation upon his participation in an effective rehabilitation effort was a reasonable exercise of the sentencing power. That it affected the defendant’s ability to exercise constitutionally protected rights, in this case the liberty interest implicated by forced attendance at a residential facility, does not by itself invalidate the probationary requirement. See United States v. Tonry, 605 F.2d 144, 150 (5th Cir. 1979).
Here, the defendant, in lieu of commitment to a State prison, was permitted to participate in a residential treatment program which, if successful, could have had a rehabilitative bearing on factors in his life that contributed to his criminal behavior. It provided an opportunity to remain an active member of society. See Commonwealth v. Durling, 407 Mass. 108, 111 (1990). While the defendant has not created a record on the subject, it appears that the exact time in which the defendant was to *32complete the program was not prescribed by the court4; the defendant could presumably have left one treatment program and enrolled in a different one; and the conditions at the treatment facility were undoubtedly more congenial than those that the defendant was likely to encounter at Cedar Junction. Perhaps most important, the time spent by the defendant at the Steven Miller House, together with other, more limited conditions, were part of a bargain whereby in return the defendant received the benefit of eradication of a five-year committed sentence that he would otherwise have been required to serve. This was not the equivalent of the involuntary confinement characteristic of a prison sentence.
Thus, at least for the purpose of determining credit for time spent in confinement, an inpatient drug treatment program as a condition of probation does not equal incarceration. See Reno v. Koray, 515 U.S. 50, 60 n.4 (1995) (applying similar logic in denying defendant credit for time spent awaiting treatment in halfway house). See also Massachusetts Sentencing Commission, Report to the General Court, at 33 (April 10, 1996) (“residential programming” and “substance abuse treatment” listed as alternatives to prison). This is not to say that there are no circumstances in which a condition of probation might be the equivalent of incarceration for which a defendant would be entitled to credit. Restrictions on a probationer’s fundamental rights are not without limits. Commonwealth v. LaFrance, 402 Mass. 789, 792-793 (1988). However, in such a case, there must be a showing that the deprivation of liberty to which the defendant was subjected approached incarceration. Aside from a self-serving affidavit by the defendant that the judge was not required to credit, see Commonwealth v. Grace, 370 Mass. 746, 751-752 (1976), no such showing was made here.
3. The five-year committed sentence. While the issue was not raised by the defendant below, we choose to address on the merits his contention that a five-year segment of the sentence he is presently serving is unlawful because he has been denied credit he should have received for that five-year period. His *33contention is based on the fact that, upon the successful completion of a probationary period (including the stay at the Steven Miller House) on December 1, 1991, a judge revoked a five-year committed portion of a State prison sentence, leaving in place an eight- to ten-year suspended sentence with a new probationary period of three years. This, he argues, failed to reflect that he had satisfied the five-year committed portion of the sentence by successfully completing the probationary requirements and by obtaining vacation of that portion; that therefore all that remained was a three- to five-year suspended sentence; and that reimposition of the full eight- to ten-year suspended term (the suspension subsequently being revoked for later improper behavior) violated his right under the Fifth Amendment to the United States Constitution against multiple punishments for the same offense. See North Carolina v. Pearce, 395 U.S. 711, 718-719 (1969).
This argument misconceives what took place after the defendant successfully completed the probationary period between December 15, 1989, and December 1, 1991. The judge did not revoke five years of an eight- to ten-year suspended sentence. He revoked only the requirement that those five years actually be served in State prison. That left the full eight- to ten-year suspended sentence in place and available to be imposed as a committed sentence in the event of a later probation violation. Contrary to the defendant’s position, five years were not eradicated for this purpose. The lack of logic of giving credit for five years of confinement during which the defendant served not a single day speaks for itself.
Order denying defendant’s motion to correct mittimus affirmed.
Because of then-available “good time credits,” the defendant had actually served substantially less than two and one-half years.
At the time of this sentencing in 1989, a judge imposing sentence following a probation violation could “split” the previously determined sentence. The judge did that here. That is no longer permissible. See Commonwealth v. Holmgren, 421 Mass. 224, 228 (1995) (“when probation is revoked, the original suspended sentence must be imposed, if the time has expired within which the sentence may be revised or revoked”). The judge retains the authority not to revoke probation.
The defendant originally sought credit for 215 days, but concedes that he has been unable to establish that he was confined for thirty of those days.
Note that the stay of imposition of sentence was approximately two years, while the defendant’s time at the Steven Miller House was approximately six months.