What's the difference between 在 and 于 as a preposition? When I was writing a simple paragraph about 自我介绍, I wanted to say that "I was born in XXX."

I wasn't sure about how to say it and then looked for some examples of how to say it in Chinese and came across two characters :

"在" and "于"
(I just knew about 于, I had never paid attention to this character before).

Both can mean "in, on, at" and can be used as a preposition to indicate a location as well.

Now, what's the difference between two characters?

Will there be any difference if I say :


  我出生在XXX。


and


  我出生于XXX。


???

Thank you!
王得屹's answer is basically correct, 在 is used in colloquial sentences more and 于 is used in literary sentences more. 

I would provide examples to illustrate the point more clearly:

"生(于)中国" = "出生(在)中国" (we don't say 生在中国 because 生 is more literary, 在 is more colloquial, mixing the two make it sound unnatural)

"逝(于)日本" = "(在)日本逝世" (we don't say 逝在日本 because 逝 is more literary, 在 is more colloquial, mixing the two make it sound unnatural; meanwhile, 死 and 在 in 死在日本 are both colloquial terms)

"生于中国" and "逝于日本" are more literary

"出生在中国" and "在日本逝世" / 死在日本 are more colloquial

unlike 逝, 逝世 is more suitable for colloquial sentences