BEIJING — When the coronavirus epidemic began its relentless march around the world, China’s diplomats reacted harshly toward countries that shut their borders, canceled flights or otherwise restricted travel.

Italy was overreacting when it did so, Qin Gang, a vice minister of foreign affairs, told his counterpart in February. The United States was stoking fear and panic, a spokeswoman, Hua Chunying, said. “True feeling shines through in hardship,” she said back then.

Now China is doing the same, undercutting its own diplomatic efforts to win sympathy and support by imposing travel restrictions that it once called unnecessary. They include 14 days of quarantine for travelers from Italy, Iran, South Korea and Japan. Almost everyone flying into Beijing faces a similar fate, regardless of departure point.

“They have a toolbox that only seems to have a hammer,” said Jörg Wuttke, the president of the European Chamber of Commerce in China, who is now himself in quarantine in his Beijing home after returning from Europe last Friday.