
208 N.J. Super. 492 (1986)
506 A.2d 373
STATE OF NEW JERSEY, PLAINTIFF-RESPONDENT,
v.
WILLIAM HILL, DEFENDANT-APPELLANT.
Superior Court of New Jersey, Appellate Division.
Submitted February 13, 1986.
Decided March 5, 1986.
*493 Before Judges FRITZ, GAYNOR and BAIME.
Thomas S. Smith, Acting Public Defender, attorney for defendant-appellant (Daniel V. Gautieri, Assistant Deputy Public Defender, of counsel and on the letter-brief).
W. Cary Edwards, Attorney General of New Jersey, attorney for plaintiff-respondent (Katherine F. Graham, Deputy Attorney General, of counsel and on the letter-brief).
PER CURIAM.
Defendant appeals from an order of the Superior Court, Law Division, denying his motion to correct an allegedly illegal sentence. Although he has phrased it in a variety of ways, defendant, who was convicted on a Camden County indictment, claims that the trial judge erroneously refused to credit him with time spent in the Cumberland County Jail awaiting disposition of unrelated charges. We disagree and affirm.
The salient facts are not in dispute. On July 18, 1982 defendant, armed with a starter pistol, entered a movie theater in Cherry Hill and demanded money from two persons in the manager's office. After threatening the victims, defendant *494 fled with approximately $2,000. Defendant remained a fugitive until November 9, 1982 when he was arrested in Cumberland County while incarcerated there on unrelated charges. Following his arrest on November 23, 1982, the Camden County Prosecutor filed a detainer against defendant based upon charges emanating out of the Cherry Hill indictment. On March 3, 1983 the Camden County grand jury returned a five-count indictment charging defendant with first degree robbery (N.J.S.A. 2C:15-1), possession of a firearm for an unlawful purpose (N.J.S.A. 2C:39-4a), second degree burglary (N.J.S.A. 2C:18-2), aggravated assault (N.J.S.A. 2C:12-1b(4)) and possession of a handgun without a permit (N.J.S.A. 2C:39-5b). Pursuant to an agreement with the State, on November 4, 1983 defendant entered retraxit pleas of guilty to first degree robbery and possession of a firearm for an unlawful purpose. On January 5, 1984 the trial judge imposed concurrent custodial terms of ten years and directed that defendant serve a period of five years without parole eligibility. The judge additionally assessed penalties totaling $50 payable to the Violent Crimes Compensation Board and dismissed the remaining charges.
In imposing sentence the judge correctly noted that the Cumberland County charges against defendant had been dismissed on October 24, 1983. The judge, thus, credited defendant with 74 days for time served following dismissal of the unrelated charges. However, he refused to give defendant credit for the period of time that he was incarcerated based upon the Cumberland County indictment. Since defendant's incarceration was not directly attributable to the Camden County charges for which he was convicted, the judge refused to credit him with time spent in jail awaiting disposition of the Cumberland County indictment. Defendant's motion to correct the sentence and credit him with the time spent in the Cumberland County jail was subsequently denied. This appeal followed.
*495 We agree with the trial judge's conclusion that the existence of the detainer did not entitle defendant to credit for time spent awaiting disposition of the unrelated Cumberland County charges. Of course, we recognize that R. 3:21-8 requires a judge to give a defendant credit "for any time he has served in custody in jail or in a state hospital between his arrest and the imposition of sentence." Although the rule "expresses the public policy of the State and should be liberally construed," State v. Beatty, 128 N.J. Super. 488, 491 (App.Div. 1974), it "only applies to confinement directly attributable to the particular offense giving rise to the initial incarceration." In re Hinsinger, 180 N.J. Super. 491, 499 (App.Div. 1981); State v. Council, 137 N.J. Super. 306, 308 (App.Div. 1975); State v. Brandfon, 38 N.J. Super. 412 (Cty.Ct. 1955), aff'd o.b. 40 N.J. Super. 328 (App.Div. 1956). Even where the defendant's incarceration is the product of an illegal sentence, "unlike money on deposit in the bank or a credit card, it may not be drawn on or credited against penalties imposed" for other criminal activities. State v. Marnin, 108 N.J. Super. 442, 445 (App.Div. 1970), certif. den. 59 N.J. 435 (1971), cert. den. 400 U.S. 835, 91 S.Ct. 70, 27 L.Ed.2d 67 (1970).
It is not uncommon for a defendant to be incarcerated on charges for which he is later acquitted or which are subsequently dismissed. This is unfortunate. Nevertheless, we perceive great mischief flowing from a rule which would accord such individuals credit against custodial sentences on wholly unrelated charges.
In any event, we have repeatedly recognized that "[t]he granting of such a credit is at best discretionary, based upon the general equities of the situation, and is not a matter of due process" or right. State v. Marnin, supra, 108 N.J. Super. at 445. See also State v. Allen, 155 N.J. Super. 582, 584-585 (App.Div. 1978), certif. den. 81 N.J. 405 (1979). These requirements are certainly satisfied when, as here, "an individual in defendant's position is afforded an opportunity to inform the *496 court, on the sentencing for the later conviction," of his prior incarceration on unrelated charges so that it might be taken into consideration. State v. Marnin, supra, 108 N.J. Super. at 445.
Applying these principles, we are entirely satisfied that the trial judge did not abuse his discretionary powers. We note that another detainer was filed against defendant while he was incarcerated in Cumberland County. Apparently, defendant was convicted of those charges. The custodial terms imposed here are to run concurrently with the sentence given on the unrelated conviction. We also emphasize that defendant did not post bail on either those charges or the Cumberland County indictment. Moreover, the record is barren of any evidence from which it might be inferred that disposition of the Cumberland County charges was delayed or in any other way affected by the Camden County detainer. It is abundantly clear from the record that the Camden County detainer had no effect upon the period of time for which defendant was incarcerated on the Cumberland County indictment. In sum, we discern no justifiable basis to disturb the trial judge's decision.
Accordingly, the order of the Law Division is affirmed.
