Joel 3:2 is speaking of a prophecy that is yet to be fulfilled. The valley of Jehoshaphat is believed to be the Kidron Valley, located in the east of Jerusalem between the Mount of Olives and the Old City.
God says:
"I will gather all the nations
And bring them down to the valley of Jehoshaphat.
Then I will enter into judgment with them there
On behalf of My people and My inheritance, Israel,
Whom they have scattered among the nations;
And they have divided up My land." (Joel 3:2)
God has not yet entered into judgment with the nations. He will judge the nations based on how they treated Israel.
God said a long time ago that He will bless those who bless Israel and curse those who curse Israel (Genesis 12:3, Genesis 27:29).
The Lord Jesus will come to judge the nations when He comes to reign on earth. This judgment is different from the judgment at the great white throne in Revelation 20:11-15. That judgment in Revelation 20 is the judgment of all the dead, according to their deeds, which will occur after Jesus' thousand-year reign is over and the last rebellion, led by Satan, is put down. Then all the unbelievers will be judged at that time.
This judgment in Joel 3:2, however, is the judgment Jesus will give at the beginning of His thousand-year reign on earth.
Jesus is the Son of David and Jewish by birth when He came to earth 2000 years ago. When He comes again to reign, He will judge all the antisemitic peoples who have warred against Israel.
In particular, God says:
"Moreover, what are you to Me, O Tyre, Sidon and all the regions of Philistia? Are you rendering Me a recompense? But if you do recompense Me, swiftly and speedily I will return your recompense on your head." (Joel 3:4)
Modern-day Tyre and Sidon are in Lebanon. The regions of Philistia might include regions around Israel where Palestinians dwell, because the word Palestine is derived from the Hebrew word Philistia. Modern-day Palestinians and Israelis have great conflicts with one another. They had conflicts in the past as well. Israel has had conflicts with Lebanon as well.
Joel goes onto say:
"The sun and moon grow dark
And the stars lose their brightness." (Joel 3:15)
Jesus said the same thing when He declared: "But immediately after the tribulation of those days the sun will be darkened, and the moon will not give its light, and the stars will fall from the sky, and the powers of the heavens will be shaken. And then the sign of the Son of Man will appear in the sky, and then all the tribes of the earth will mourn, and they will see the Son of Man coming on the clouds of the sky with power and great glory." (Matthew 24:29-30)
So the prophecy in Joel is related to Jesus' second coming, when He will take control of the earth after the Tribulation and immediately judge the nations for what they have done to Israel.
"The Lord roars from Zion
And utters His voice from Jerusalem,
And the heavens and the earth tremble.
But the Lord is a refuge for His people
And a stronghold to the sons of Israel.
Then you will know that I am the Lord your God,
Dwelling in Zion, My holy mountain." (Joel 3:16-17)
Jesus will reign from Israel in Jerusalem. He will punish the nations that have done wrong to Israel and avenge the blood of the Jewish people.
"But Judah will be inhabited forever
And Jerusalem for all generations.
And I will avenge their blood which I have not avenged,
For the Lord dwells in Zion." (Joel 3:19-21)