Hi I have a JSON object which has a "TimeStamp" filed as below
"timestamp":1602830127
Now I want to compare this time stamp is less than 3 minutes from my current time.
How can I do this in Java?
And also I need to convert this into ZonedDateTime
format as well
I tried something like this because then I can get it as a long number
long timestamp2 = 1602830127;
for (int i = 0; i < 10; i++) {
timestamp2 = timestamp2 + 10;
acceptEvent(new Event(new Timestamp(timestamp2).toInstant().atZone(ZoneId.systemDefault()), UUID.randomUUID().toString()));
//acceptEvent(new Event(ZonedDateTime.now().minusSeconds(i), UUID.randomUUID().toString()));
}
But it always returns a wrong as 1970-01-19T18:43:50.137+05:30[Asia/Colombo] How can I achive these 2? Please help me. Thank you!