Here you can find the source of roundToNearestSecond(long time)
static long roundToNearestSecond(long time)
//package com.java2s; public class Main { static long roundToNearestSecond(long time) { return ((time + ((time >= 0) ? 500 : -500)) / 1000) * 1000; }/*from w ww . j av a2 s .c o m*/ }