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 7679693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:56:12+00:00 2026-05-31T17:56:12+00:00

I have an ArrayList of Timestamps. I want to split this ArrayList into several

  • 0

I have an ArrayList of Timestamps. I want to split this ArrayList into several ArrayLists ad put them into a HashMap grouped by the day. So all the Timestamps for 14-01-2011 go together, all the Timestamps for 29-01-2012 go together, etc…

Pseudocode –

myTimestampMap['21-03-2012'] = ArrayList { myTimestamp[0], myTimestamp[1], myTimestamp[2] };
myTimestampMap['22-03-2012'] = ArrayList { timeStmyTimestamp[3], myTimestamp[4]};

I know the following algorithm will work –

  • Take the first value in the Timestamps ArrayList, find it’s ‘day’ and assign that to a variable called currentDay (so if the first Timestamp is 12 March 2012 14:26PM, assign 12 March 2012 00:00AM to currentDay).

  • Now iterate over the Timestamps and if getDay() is not within currentDay + 24 hours, assign currentDay = getDay() (at 00:00AM), create a new key in the HashMap and put all the following Timestamps in it until we come to a Timestamp where again getDay() is not within currentDay + 24 hours, then just repeat.

    1. The thing I am unsure of is if I have a Timestamp that signifies, say, 12 March 2012 16:57PM, I have to derive a Timestamp (currentDay) from that that signifies 12 March 2012 00:00AM. How would I do that?
    2. I also need to then check if a given Timestamp is within 24 hours of the currentDay Timestamp. How would I do that?
  • 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-05-31T17:56:14+00:00Added an answer on May 31, 2026 at 5:56 pm

    Assuming that you can ignore time zone issues (e.g. all the times you have are in UTC and you don’t mind leap seconds!)…

    If you convert the date and time into a number of seconds since some reference date (epoch time format uses 1/1/1970 00:00:00), then you can just do seconds integer divided by the number of seconds in a day) to convert it to an integer representing the number of days.

    To check if a given time stamp is in the same day then you’d simply compare the values / 86400.

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

Sidebar

Related Questions

I have an arraylist called 'pri1', I want this array list to be available
I have an ArrayList<String> , and I want to remove repeated strings from it.
I have an ArrayList that I want to use to hold RaceCar objects that
I have `a string example = this site holds all the examples from The
I have an ArrayList in my Servlet code. Now, I want to show that
I have an Arraylist of HashMap . Each HashMap element contains two columns: column
I have made an ArrayList in Java and put some integers and some doubles
i have an arraylist and i want to add and remove many items at
I have an Arraylist . If user enter the same number secondly I want
I have an ArrayList of Path values. I need to convert it into String

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.