Here you can find the source of getRoundedSeconds(long seconds, long interval)
public static long getRoundedSeconds(long seconds, long interval)
//package com.java2s; //License from project: Open Source License public class Main { public static long getRoundedSeconds(long seconds, long interval) { long mod = seconds % interval; if (mod == 0) { return seconds; }// w w w . j av a 2 s . co m if (mod > (interval / 2)) { return (seconds - mod) + interval; } return seconds - mod; } }