I know that the standard UNIX epoch time is 1/1/70 and I can use this variable to convert current time to UNIX time:
int time = (int) ((System.currentTimeMillis())/1000);
(Note: I know it's normally stored as a 64-bit long but I need it to be 32 bit, hence the cast to int).
My question is - are there any built-in methods in Java where you can pass in a different date as the "epoch date." What I am trying to get is a timestamp in # of seconds since a particular date. I.e. I would like to define January 1, 2015 as MY epoch. And then each future date would be # of seconds since 1/1/2015.
If there's no Java library that provides that capability, any ideas on how to do this?
Thanks,
Tim
Copyright Notice:Content Author:「timsterc」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24539885/use-different-date-as-unix-epoch-time-in-java