how to get seconds from java long, I'm storing it in mssql DB as bigint
I store the long values in mssql using bigint so I could do something 开发者_StackOverflow社区like this:
--@start and @end are bigint
set @duration = @start - @end
now I need some additional operation so I could get the duration in seconds, anybody knows how ?
I guess it really depends on what those values were .. you say Java long, so it makes me wonder if you're doing something like System.currentTimeMillis() and then shoving that value in the database. If that's the case, then just dividing the duration by 1,000 would get you seconds.
More information in the question would be helpful.
import java.util.concurrent.TimeUnit;
...
/* "seconds" is the number of seconds sinced the epoch began. */
long seconds = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
精彩评论