When to use 0L?

Yes, exactly, the L means that the constant is long, so you have to use it if you want to assign it correctly to long variable.
0L is 32 bit constant in compare with 0 which is just 16bit and upper bytes stay unchanged in the first case.