Jamie Sullivan (29) could not explain his behaviour, other than to say he was not sleeping at the time, his lawyer said.
Judge David McHugh adjourned sentencing to a date in September, saying he wanted more information about the defendant's mental health issues.
Judge McHugh also said that the case involved "a bizarre set of facts".
The defendant, of Manorfields View in Clonee, admitted trespassing at a house at Latchford Green in Clonee, Dublin 15, on August 23 last year.
Sergeant Maria Callaghan told Blanchardstown District Court that gardaí received a call that an intruder was in the homeowner's kitchen.
Sgt Callaghan said gardaí went to the scene and found the defendant wearing the injured party's clothes. He had no excuse for his behaviour.
Sullivan had entered the house through the front door, which was unlocked, Sgt Callaghan said.
The defendant co-operated with gardaí and left the scene with them, and was subsequently arrested and charged, the court heard. Sullivan had never been in trouble before, the sergeant said.
Defence lawyer Ciaran MacLoughlin said Sullivan worked as a software engineer.
Mr MacLoughlin said the defendant could not explain his behaviour, which he accepted was bizarre. Sullivan did not know why he had gone into the man's house nor why he had put on the injured party's clothes, the lawyer said.
Sullivan was suffering from insomnia at the time of this incident, and he was not sleeping very well, Mr MacLoughlin added. He subsequently suffered a breakdown, and spent some time as an involuntary patient in hospital.
Mr MacLoughlin said Sullivan was now doing much better, was taking his medication and had reunited with his partner.
The lawyer also said nothing had been stolen by Sullivan.
Judge McHugh adjourned the matter to September, saying he wished to have more information on the defendant's psychotic episode.
If Sullivan stayed out of trouble, Judge McHugh indicated he would strike out the charge and leave the defendant without a conviction.