וַיִּשְׁלַ֣ח אֵלָ֣יו מַלְאָכִ֣ים ׀ לֵאמֹר֩ ׀ מַה־לִּ֨י וָלָ֜ךְ מֶ֣לֶךְ יְהוּדָ֗ה לֹא־עָלֶ֨יךָ אַתָּ֤ה הַיּוֹם֙ כִּ֚י אֶל־בֵּ֣ית מִלְחַמְתִּ֔י וֵאלֹהִ֖ים אָמַ֣ר לְבַֽהֲלֵ֑נִי חֲדַל־לְךָ֛ מֵאֱלֹהִ֥ים אֲשֶׁר־עִמִּ֖י וְאַל־יַשְׁחִיתֶֽךָ׃
Aber er sandte Botschafter zu ihm und sagte: 'Was habe ich mit dir zu tun, du König von Juda? Ich komme heute nicht gegen dich, sondern gegen das Haus, mit dem ich Krieg habe; und Gott hat den Befehl gegeben, mich zu beschleunigen; verbiete dir, dich in Gott einzumischen, der bei mir ist, damit er dich nicht vernichtet.'
From David to Destruction
Yoshiyahu HaMelech, entirely unnecessarily, enters into battle with Paroh Necho. Paroh Necho, according to the account in Divrei HaYamim II 35:21, even communicates to Yoshiyahu HaMelech that he is merely using Eretz Yisrael as a route to fight the Babylonians at the Battle of Carchemish. According to Chazal (Ta’anit 22b), Yirmiyahu Hanavi warns Yoshiyahu HaMelech against intervening.
Rashi
I will cause the sun to set at midday—When there will be exceeding tranquility, a sudden downfall will come and our Rabbis said: This refers to the day of Josiah who died by the “peaceful sword” as our Rabbis said: There was no more peaceful sword than Pharaoh-Neco who said to Josiah, (II Chron. 35:21) “What do I have to do with you, O king of Judah; not upon you yourself today.” Not upon you do I come today, but to pass through your land “to the house against which I wage war etc.” [from Mo’ed Katan, Ta’anith 22a]