2A:67-27.Ā  Time of hearing;Ā  notice
When the writ is returned, the court may hold the hearing immediately unlessĀ  the validity of a detention on any civil process, or the sanity or insanity ofĀ  the party is to be determined, and may, in any case, set a date for the hearingĀ  which shall be not more than 5 days after the return of the writ unless forĀ  good cause additional time is allowed.

Notice of the time and place set for a later hearing shall be served at least 2 days prior thereto or at such earlier time as the court may order, by the applicant upon the defendant, and (a) if the party is in custody on any criminal matter, upon the county prosecutor of the county wherein the alleged offense was committed, or (b) if the party is in custody on any civil process, upon each person having an interest in continuing the confinement or restraint or upon his attorney, or (c) if the party is in custody of any hospital for theĀ  insane or other institution, service shall be made upon the person or personsĀ  upon whose application he was committed to the hospital or institution, andĀ  upon the medical director or other head officer of the hospital orĀ  institution.
Ā 
L.1951 (1st SS), c.344.
Ā