The book series does not specifically tell in what year Harry Potter gets married, but it is implied in the Epilogue of Harry Potter and the Deathly Hallows, when nineteen years, after the fight at Hogwarts, he was married. We can presume he got married before having his first child which is in between 2002 and 2006. So he got married in his early twenties and was most likely married before he was 22.