Decades.
I thought I was speaking German after spending months in a Goethe Institute. Then a little kid told me that one learns German “with great effort.” He used the word Muehe (with an umlaut). = Mühe
I thought I had learned German when I studied Germanistik at a German University. Then I had to deliver a paper to the entire Seminar and realized that they were hearing an American trying to speak German.
I thought I had arrived when I did a book presentation of my second book published in Germany. Then a guy wanted me to do a radio interview and I performed at the level of a beginner.
Exactly fifty years after I took my first German class, I am not sure I actually speak German. I have friends with whom I have only spoken German and I have spent a sabbatical in Berlin and dealt with German Publishers. I am still waiting for the jury to say that I actually speak German.
Now I am an old guy and Germans generally understand me when I speak. So I guess the answer is fifty years. It takes about fifty years to learn to speak German.
And it is worth the effort.