
584 So.2d 158 (1991)
E.R., a Child, Appellant,
v.
STATE of Florida, Appellee.
No. 89-02851.
District Court of Appeal of Florida, Second District.
August 9, 1991.
Thomas A. McDonald of McDonald & Shearer, Lakeland, for appellant.
Robert A. Butterworth, Atty. Gen., Tallahassee and Davis G. Anderson, Asst. Atty. Gen., Tampa, for appellee.
RYDER, Judge.
Appellant was adjudicated delinquent and found guilty of battery upon school board employee, resisting arrest without violence, burglary of a dwelling and aggravated battery, and committed to the Department of Health and Rehabilitative Services without being given credit for time served in secure detention pending adjudication. Before us, he argues that failure to give credit for this period constitutes an illegal sentence. A detainee must be granted credit for time served prior to conviction in any institution serving as the functional equivalent of a county jail. Tal-Mason v. State, 515 So.2d 738 (Fla. 1987). Although rehabilitation may outweigh retributive punishment as a purpose of the Florida Juvenile Justice Act, secure detention closely resembles county jail in that appellant is deprived of his liberty, and is in the total custody and control of the state at all times. We agree.
We affirm the adjudication and commitment but remand to the trial court for entry of an order granting appellant a credit of eighty-eight days for time served in secure detention against the period of commitment which shall terminate at his nineteenth birthday, or as otherwise provided by law.
SCHOONOVER, C.J., and PATTERSON, J., concur.
