A former milkman threw a bag of cannabis out of a car window when gardai stopped him during a routine patrol.
Wayne Gaffney (28) has battled a problem with cannabis since he was a teenager, but he claimed he has been free from drugs since this incident.
Judge David McHugh fined Gaffney €150 and imposed a four-month sentence suspended for two years.
The defendant, of Ballygall Parade in Finglas, admitted before Blanchardstown District Court to possession of cannabis as well as having the drug for sale or supply at Collins Green in Finglas on April 23, 2014.
Sergeant Mary Doherty said gardai were on routine patrol when they stopped a vehicle.
Sgt Doherty said Gaffney was seen throwing a bag out of the vehicle. It contained cannabis, with a street value of €1,200.
Defence lawyer Ciaran MacLoughlin said the defendant had a difficult childhood, was bullied at school and started smoking cannabis aged 13.
He settled down in his late teens and had a child. During this time, he was clean of drugs and worked as a milkman, the lawyer said.
However, his former partner suffered from depression and the relationship broke up, and Gaffney started smoking cannabis again.
The court heard the defendant has been in a new relationship for the last year and has had a second child.
Mr MacLoughlin also said Gaffney has been clean of drugs since this incident in June 2014 and is providing clean urines.