First-principles study of electronic properties of La2Hf2O7 and Gd2Hf2O7