Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:06:44+00:00 2026-06-03T06:06:44+00:00

I have an ArrayList of elements with a timestamp. Given an element of this

  • 0

I have an ArrayList of elements with a timestamp.

Given an element of this array, I would like to select all the elements happing a certain time before and after that given element.

The problem is that this time stamp goes to 60 000 milisec and then start again from zero.

So if I would like to get all the elements happening, say 1000 milisec before and after the element with timestamp 59 999 I don’t know how to do this.

I have been looking at the modulus operation but I don’t seem able to make it work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:06:46+00:00Added an answer on June 3, 2026 at 6:06 am

    Try this:

    List<Integer> timestamps;
    int target = 59999; // matches are from 58999 to 999 (wrapped around)
    for (Integer timestamp : timestamps) {
        if (Math.abs(timestamp + 60000 - target) <= 1000 || Math.abs(timestamp - target) <= 1000) {
            // this timestamp is a match
        }
    }
    

    This code simply check twice – once each for roll-over and non-roll-over.

    I’ve tested it and it works for “roll-under” as well – ie when the target is less than 1000 (so the range would be between 59000 + target and target)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select all elements that have a given class and remove them
I have a ArrayList, with elements something like: [string,has,was,hctam,gnirts,saw,match,sah] I would like to delete
I have written this code to join ArrayList elements: Can it be optimized more?
I have an arrayList with 30 elements. I'd like to create many sublists of
I have an arraylist called 'pri1', I want this array list to be available
I have an ArrayList full of strings arrays that I built like this: String[]
I have the elements in Arraylist like Sowmya/20 Ramya/67 Archana/54 Kavitha/48 . . .
I have a problem of adding elements into an ArrayList. Each time I do
I have 3 ArrayList s and a JTable . I would like to be
I have 4 arraylist in jsp and I want to get elements of lists

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.