Judge Bernadette Farnam said there were faults on all sides, and it was a life-changing situation for the two managers.
She sentenced each of the men to 275 hours community work, plus a $10,000 fine plus court costs.
Castlerock Dairies Limited has also been fined $37,500, plus prosecution costs of $11,500.
DairyNZ's animal welfare specialist, Helen Thoday said the well-being of animals was at the heart of any good farming business.
"What occurred at Castlerock farm in 2015 is appalling. It's just not okay for animals to be treated in this manner.
"The farming community around New Zealand will be appalled - they care about their animals, and treat them with care and respect," she said.
"This case of mistreatment is a sad slur on the good reputation of the thousands of good dairy farmers who are committed to providing their animals with a healthy and safe environment, and farming to high standards.
"We welcome this prosecution by MPI, and the prosecution of anyone who does not look after their animals.
"Cruel and illegal practices are never condoned or accepted as part of dairy farming."
Ms Thoday said the prosecution sent a clear message to anyone with animals to care for them, to monitor their health and well-being, and if they are concerned to ask for help.