@Test public void getDelayTilllUUIDBroadcastInSeconds() throws ParseException { System.out.println(Math.ceil(23/15.0)); System.out.println(Math.ceil(8/15.0)); }
public static int getDelayTilllUUIDBroadcastInSeconds(long ts) { SimpleDateFormat minuteFormat = new SimpleDateFormat("mm"); SimpleDateFormat secondFormat = new SimpleDateFormat("ss"); Date dd = new Date(ts); int minute = Integer.parseInt(minuteFormat.format(dd)); int second = Integer.parseInt(secondFormat.format(dd)); List<Integer> intervals = new LinkedList<>(); for (int i = 0; i < 60/Constants.UUIDGenerationIntervalInMinutes; i++) { intervals.add(i*Constants.UUIDGenerationIntervalInMinutes); } int delay = 0; if (second == 0 && intervals.contains(minute)) { delay = 0; } else { int closestIntervalIndex = 0; if (minute < intervals.get(intervals.size()-1)) { for (int i = 0; i < intervals.size(); i++) { if (minute >= intervals.get(i)) { closestIntervalIndex = i+1; } } } int targetMinute = intervals.get(closestIntervalIndex); int secondDelay = 60-second; int minuteDelay = targetMinute-minute-1; if (targetMinute == 0) { secondDelay = 60-second; minuteDelay = 60-minute-1; } delay = minuteDelay*60+secondDelay; } return delay; }
TimeUtils { public static int getDelayTilllUUIDBroadcastInSeconds(long ts) { SimpleDateFormat minuteFormat = new SimpleDateFormat("mm"); SimpleDateFormat secondFormat = new SimpleDateFormat("ss"); Date dd = new Date(ts); int minute = Integer.parseInt(minuteFormat.format(dd)); int second = Integer.parseInt(secondFormat.format(dd)); List<Integer> intervals = new LinkedList<>(); for (int i = 0; i < 60/Constants.UUIDGenerationIntervalInMinutes; i++) { intervals.add(i*Constants.UUIDGenerationIntervalInMinutes); } int delay = 0; if (second == 0 && intervals.contains(minute)) { delay = 0; } else { int closestIntervalIndex = 0; if (minute < intervals.get(intervals.size()-1)) { for (int i = 0; i < intervals.size(); i++) { if (minute >= intervals.get(i)) { closestIntervalIndex = i+1; } } } int targetMinute = intervals.get(closestIntervalIndex); int secondDelay = 60-second; int minuteDelay = targetMinute-minute-1; if (targetMinute == 0) { secondDelay = 60-second; minuteDelay = 60-minute-1; } delay = minuteDelay*60+secondDelay; } return delay; } }
TimeUtils { public static int getDelayTilllUUIDBroadcastInSeconds(long ts) { SimpleDateFormat minuteFormat = new SimpleDateFormat("mm"); SimpleDateFormat secondFormat = new SimpleDateFormat("ss"); Date dd = new Date(ts); int minute = Integer.parseInt(minuteFormat.format(dd)); int second = Integer.parseInt(secondFormat.format(dd)); List<Integer> intervals = new LinkedList<>(); for (int i = 0; i < 60/Constants.UUIDGenerationIntervalInMinutes; i++) { intervals.add(i*Constants.UUIDGenerationIntervalInMinutes); } int delay = 0; if (second == 0 && intervals.contains(minute)) { delay = 0; } else { int closestIntervalIndex = 0; if (minute < intervals.get(intervals.size()-1)) { for (int i = 0; i < intervals.size(); i++) { if (minute >= intervals.get(i)) { closestIntervalIndex = i+1; } } } int targetMinute = intervals.get(closestIntervalIndex); int secondDelay = 60-second; int minuteDelay = targetMinute-minute-1; if (targetMinute == 0) { secondDelay = 60-second; minuteDelay = 60-minute-1; } delay = minuteDelay*60+secondDelay; } return delay; }  }
TimeUtils { public static int getDelayTilllUUIDBroadcastInSeconds(long ts) { SimpleDateFormat minuteFormat = new SimpleDateFormat("mm"); SimpleDateFormat secondFormat = new SimpleDateFormat("ss"); Date dd = new Date(ts); int minute = Integer.parseInt(minuteFormat.format(dd)); int second = Integer.parseInt(secondFormat.format(dd)); List<Integer> intervals = new LinkedList<>(); for (int i = 0; i < 60/Constants.UUIDGenerationIntervalInMinutes; i++) { intervals.add(i*Constants.UUIDGenerationIntervalInMinutes); } int delay = 0; if (second == 0 && intervals.contains(minute)) { delay = 0; } else { int closestIntervalIndex = 0; if (minute < intervals.get(intervals.size()-1)) { for (int i = 0; i < intervals.size(); i++) { if (minute >= intervals.get(i)) { closestIntervalIndex = i+1; } } } int targetMinute = intervals.get(closestIntervalIndex); int secondDelay = 60-second; int minuteDelay = targetMinute-minute-1; if (targetMinute == 0) { secondDelay = 60-second; minuteDelay = 60-minute-1; } delay = minuteDelay*60+secondDelay; } return delay; }  static long getNDaysForward(int N); static long getTime(); static long getPreviousGenerationTimestamp(long ts); static int getDelayTilllUUIDBroadcastInSeconds(long ts); }
TimeUtils { public static int getDelayTilllUUIDBroadcastInSeconds(long ts) { SimpleDateFormat minuteFormat = new SimpleDateFormat("mm"); SimpleDateFormat secondFormat = new SimpleDateFormat("ss"); Date dd = new Date(ts); int minute = Integer.parseInt(minuteFormat.format(dd)); int second = Integer.parseInt(secondFormat.format(dd)); List<Integer> intervals = new LinkedList<>(); for (int i = 0; i < 60/Constants.UUIDGenerationIntervalInMinutes; i++) { intervals.add(i*Constants.UUIDGenerationIntervalInMinutes); } int delay = 0; if (second == 0 && intervals.contains(minute)) { delay = 0; } else { int closestIntervalIndex = 0; if (minute < intervals.get(intervals.size()-1)) { for (int i = 0; i < intervals.size(); i++) { if (minute >= intervals.get(i)) { closestIntervalIndex = i+1; } } } int targetMinute = intervals.get(closestIntervalIndex); int secondDelay = 60-second; int minuteDelay = targetMinute-minute-1; if (targetMinute == 0) { secondDelay = 60-second; minuteDelay = 60-minute-1; } delay = minuteDelay*60+secondDelay; } return delay; }  static long getNDaysForward(int N); static long getTime(); static long getPreviousGenerationTimestamp(long ts); static int getDelayTilllUUIDBroadcastInSeconds(long ts);  }