<Tr> <Th_colspan="2"> Envoy </Th> </Tr> <Tr> <Th> Ambassador Kenichirō Sasae </Th> <Td> Ambassador William F. Hagerty (nominee) </Td> </Tr> <P> Japan--United States relations (日 米 関係) began in the late 18th and early 19th century, with the diplomatic but force - backed missions of U.S. ship captains James Glynn and Matthew C. Perry to the Tokugawa shogunate being of particular importance . The countries maintained relatively cordial relations after that, and Japanese immigration to the United States was prominent until the 20th century, up until the 1930s, when Japanese actions during the Second Sino - Japanese War caused the United States to impose harsh sanctions against Japan, ultimately leading to the Japanese surprise attack against the US naval base at Pearl Harbor, opening the Pacific War theater of World War II . The United States and its Allies ultimately defeated Japan, and war ended with the American atomic bombings of the Japanese cities of Hiroshima and Nagasaki . Japan surrendered, and was subjected to seven years of military occupation by the United States, during which the American occupiers helped rebuild the country, shared American technology, and carried out widespread political and economic reforms so as to transform Japan into a democracy and a potential bulwark against Communism . Following the end of the occupation, the countries' relationship prospered again . A new military alliance treaty, an exchange of technology and culture produced a strong alliance . The countries' trade relationship has particularly prospered since then, with Japanese automobiles and consumer electronics being especially popular . </P> <P> From the late 20th century and onwards, the United States and Japan have firm and very active political, economic and military relationships . The United States considers Japan to be one of its closest allies and partners . Japan is one of the most pro-American nations in the world, with 85% of Japanese people viewing the U.S. and 87% viewing Americans favorably in 2011, 73% of Japanese people viewing Americans favorably and 69% of Japanese people viewing the U.S. favorably in 2013, going down somewhat to 66% in 2014 . And most Americans generally perceive Japan positively, with 81% viewing Japan favorably in 2013, the most favorable perception of Japan in the world, after Indonesia . </P>

When did the us and japan become allies
find me the text answering this question