I am using Android’s Calendar object and I am using the getTimeInMillis() method, but when I look at the Value it gives me it is a really long number. I am trying to replicate this format but I don’t know how as when I take the current time in 24 hour mode and convert it to milliseconds I am completely off.
Example:
Calendar.getTimeInMillis() : at 11:46 pm = 1,349,585,220,205
Time at 11:46 pm using formula[(23 * 60 * 60 * 1000) + (46 * 60 * 1000)] = 85,560,000
I’m wondering if there is some kind of formula the calendar is using to convert the current time to Milliseconds and how I can replicate this.
Thank you!
It’s the number of milliseconds since the epoch, 1/1/1970. See this article on Unix time.
(This is not precise due to not taking into account daylight savings time. Use a real datetime library!)