Beijing has cold and windy winter weather, hot dry summers, and passable spring and autumn weather. Shanghai is a bit more like Hong Kong and Taiwan. Worst weather in China are the cold months from December through February in Beijing, and the rainy season of July and August in Shanghai. Best time is April, May, October and November, worst time is December and January. June is the month of monsoons.
Weather is virtually the same year around, and no months are much better or worse than others.
It almost always rains at least a third of the time. June through September, and January and February, have slightly less rain, and are therefore the best months for a visit. Hottest and dryest months are March through June. Monsoons don't hit New Delhi, but are very much in evidence in southern India from May through September. Delhi gets frightfully hot in summer, cool-ish in winter.