On February 1, a Saturday, the defendant was in the grounds of Opoho School, on a raised hill behind the basketball courts.
He positioned himself in the "exposed area" and began to pleasure himself.
There were no children around at the time, court documents confirmed. However, a contractor who was mowing the lawns spotted the indecent act.
When the two made eye contact, the defendant moved away, but later returned to continue.
The groundsman called police and the offender was arrested.
The defendant told officers he had committed the lewd act "for a change of scenery" and because he was bored.
He was charged and had been approved for diversion, a police scheme in which defendants can avoid conviction. However, that was withdrawn following the events of April 10.
In the heart of the Covid-19 lockdown, at 10.45pm, the defendant was in the Dunedin Northern Cemetery when the 60-year-old victim entered the grounds with his dog.
As they passed each other, the defendant doubled back to follow and grabbed the man.
"The defendant held on to the victim by the buttocks for about two to three seconds," a police summary said.
He tried to engage the victim in conversation but the man fled.
In a statement, the victim said the experience made him feel "uncomfortable and a little disturbed".
He had no lasting fears for his safety, but said of the offender, "I'm concerned if his behaviour goes unchecked ... He may reoffend ... and potentially escalate his offending."
Counsel Noel Rayner said his client had only engaged with psychiatric services in February and planned to maintain regular contact.
On charges of committing an indecent act and indecent assault, Judge Large imposed 18 months' intensive supervision.
The defendant would be GPS-monitored while serving the sentence and banned from entering Opoho School or other areas specified by Probation.