When you are emphasizing your state when you were student. That would be perfect.
In English, 「When I was a student I was studying at a university in Japan.」 is the translation.
But if it is the action. Then 「学生のころ日本の大学で勉強しました」 would be better.
In English, 「 I was studied at a university in Japan when I was a student」 is the translation.
But any of the two will do :)