We investigate the first law of thermodynamics in the case of the(2+1)-dimensional Banados–Teitelboim–Zanelli black holes and Kerr–deSitter spacetimes. In particular, we focus on the integral massformulas. It is found that by assuming the cosmological constant as avariable state parameter, both the differential and integral massformulas of the first law of black hole thermodynamics in the asymptoticflat spacetimes can be directly extended to those of rotating blackholes in anti-de Sitter and de Sitter backgrounds. It should be pointedthat these formulae come into existence in any dimensions.