The 37-year-old Cocker had pleaded guilty to second-degree kidnapping.
Last June, he stormed past a guard into a middle school in Blauvelt and threatened to shoot South Orangetown Superintendent Ken Mitchell. Mitchell disarmed him during a struggle.
Police said later the gun was not loaded.
Prosecutors said Cocker had a sick child and was upset over the schools' swine flu policy.
The defense said the Cocker suffered from post-traumatic stress suffered while on the NYPD.