标签:rop author ble style ram code flag lag col
/** * 时间范围占比 * * @param st 开始时间戳 * @param et 结束时间戳 * @param cst 对比开始时间戳 * @param cet 对比结束时间戳 * @return 占比 * @author liushouyun */ public static Tuple2<Integer, Double> proportionOfTimeRange(long st, long et, long cst, long cet) { double stMax = st; double enMin = et; boolean stFlag = false; boolean etFlag = false; if (st <= cst) { stFlag = true; stMax = cst; } if (et >= cet) { etFlag = true; enMin = cet; } Tuple2<Integer, Double> tuple2; if ((enMin - stMax) <= 0) { tuple2 = Tuples.of(0, 0.0); } else if (stFlag && etFlag) { tuple2 = Tuples.of(1, OperationUtil.div((enMin - stMax), (et - st))); } else { tuple2 = Tuples.of(2, OperationUtil.div((enMin - stMax), (cet - cst))); } return tuple2; }
标签:rop author ble style ram code flag lag col
原文地址:https://www.cnblogs.com/lsy131479/p/12309221.html