Additional District and Sessions Judge Rajiv Kalra also slapped a fine of Rs 25,000 on the convict on Monday.
According to the prosecution, the case was disposed of in just four months from the date of the crime.
Pawan Kumar, a resident of Sujanpur, had entered the house of a married woman in his neighbourhood after scaling a wall on May 25, 2015. Victim was alone at the time of the incident as her husband was away to work.
A case under various sections of IPC was registered against him.