- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
List<SomeObj> list = getTodayObjects();
.....
int i = list.size() - 1;
for (; i >= 0; i--) {
SomeObj oldState = list.get(i);
if (currentObj.getTimestamp() - oldState.getTimestamp() >= 5 * MINUTE) {
value5MinAgo = oldState.getValue();
break;
}
}
for (; i >= 0; i--) {
SomeObj oldState = list.get(i);
if (currentObj.getTimestamp() - oldState.getTimestamp() >= 15 * MINUTE) {
value15MinAgo = oldState.getValue();
break;
}
}
for (; i >= 0; i--) {
SomeObj oldState = list.get(i);
if (currentObj.getTimestamp() - oldState.getTimestamp() >= 30 * MINUTE) {
value30MinAgo = oldState.getValue();
break;
}
}
for (; i >= 0; i--) {
SomeObj oldState = list.get(i);
if (currentObj.getTimestamp() - oldState.getTimestamp() >= 60 * MINUTE) {
value60MinAgo = oldState.getValue();
break;
}
}
.....
monobogdan 25.08.2021 07:46 # 0