Stephen Mullins (29) was stopped and searched after gardai saw him acting suspiciously near a known area for drug dealing.
He was jailed for nine months.
The defendant, of Lanesborough Terrace in Finglas, was found guilty of possession of knives with intent to cause injury or to intimidate another person.
Mullins is father to four children and stepfather to three children.
The incident took place near the Nutgrove Shopping Centre, Rathfarnham, on October 11 last year. Garda Niall Russell said at around 10pm he saw Mullins acting suspiciously.
Garda Russell said the area was a known area for selling drugs, and he decided to search the defendant.
The court heard that Garda Russell asked Mullins if he had anything in his pockets -- which he denied.
Garda Russell said he saw the defendant slip something from his pocket into his hand, and when he asked what it was Mullins showed him a small folding knife.
He then went to search the defendant's rucksack and was told "you won't like what's in the bag".
The garda found two large 12-inch knives in the bag, one of which had a dragon head, while the second had a curved wooden handle.
Garda Russell said Mullins told him his girlfriend's place had been smashed up, and he went out looking for the culprits. He claimed he took the knives just to show them, and to frighten them.
He admitted that his girlfriend told him not to leave the house with the knives.
Judge John Coughlan rejected defence arguments that gardai wrongly used their powers of searching a person under the Misuse of Drugs Act as a "fishing expedition" and found Mullins guilty.
Defence lawyer Kitty Perle said the defendant was the father of four children, and stepfather to three children.
Ms Perle said he had battled a problem with alcohol, which led to a more serious problem of injecting heroin, but he was currently in residential treatment. Judge Coughlan sentenced Mullins to nine months in prison and ordered the knives to be destroyed.