Six months for garbage diving? What am I missing?
The former owner of things placed in trash intended for disposal has no rights of ownership in the item and no expectation of privacy in the contents. (U.S. Supreme Court).... Moreover, it cannot be trespass since it is a business open to and inviting the public. The prosecutor is a shill for the business interest and the poor defendant doesn't know his rights in such a case. There is no crime in this scenario.
Location, location, location!
They trespassed on the property of Sweet Pea Produce to steal the food. If one of them had fallen ill, was hospitalized or died from eating from the garbage owned by Sweet Pea Produce, lawyers would have been salivating to get as much money as possible. Many states have laws that restaurants must throw the food out at the end of the day and not give to soup kitchens or to the homeless because of potential lawsuits. It's a shame too - lots of good food is thrown out because of lawsuit junkies and their attorneys.
Thus the trespassing charge.