Upvote:2
Jesus' public ministry most likely lasted about three years (see "How long was Jesus's ministry?"). He called his twelve closest disciples, including Judas, toward the beginning of that three year period (see Mark 3:13-19; Luke 6:12-16), and Judas betrayed him at the end of it. It's possible that Jesus knew Judas for an extended time before he called him as one of his twelve disciples, but we have no real information about that.
So based on what we know from the Bible text, the answer to your question is: Jesus most likely knew Judas at least three years (and possibly longer) before Judas betrayed him.