Skip to content
Advertisement

How do you create a proper Epoch calendar object in Java?

I want to create a calendar object that is the epoch date. What’s the ‘correct’ (if any) way to do it?

JavaScript

Advertisement

Answer

The ‘setTimeInMillis()’ method would work fine and be easily understood by others. It might also be clearer if you passed it 0 instead of 1. The first method has more line noise and just adds more chances that something can get screwed up in maintenance.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement