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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:23:55+00:00 2026-05-27T23:23:55+00:00

Before I mostly had to loop between days in a certain period and I

  • 0

Before I mostly had to loop between days in a certain period and I used loops like this:

for(LocalDate iDate = gv.firstDate; iDate.isBefore(gv.lastDate); iDate = iDate.plusDays(1)) {
   ...
}

Now I have a TreeMap like this:

TreeMap<LocalDate, ArrayList<Email>> dates;

I want to loop over all months from gv.firstDate to gv.lastDate and get all Emails that are within that month.

Does anyone know of a good way to do this using Joda-Time?

edit:

Having it combined with this will be great, so now get from emails from the dates TreeMap.

    for(int y = 2004; y < 2011; y++) {
        for(int m = 0; m < 12; m++) {
            // get all of that month
        }
    }
  • 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-27T23:23:56+00:00Added an answer on May 27, 2026 at 11:23 pm

    As you are using a TreeMap you could use method http://docs.oracle.com/javase/6/docs/api/java/util/NavigableMap.html#subMap%28K,%20boolean,%20K,%20boolean%29

    NavigableMap<K,V> subMap(K fromKey,
                             boolean fromInclusive,
                             K toKey,
                             boolean toInclusive)
    

    Returns a view of the portion of this map whose keys range from fromKey to toKey.

    If the keys defining the interval are not guaranteed to be in the map you can get a map containing only the values you want by doing

    for(List<Email> emails : dates.tailMap(gv.firstDate).headMap(gv.lastDate).values()) {
       for(Email email : emails) {
          // do something
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting Calculus this semester. I've used programming (or scripting) languages before, mostly PHP
This question has been asked/answered (mostly) before, BUT I've tried three things to stop
I know, variations of this question had been asked before. But my case may
I’ve mostly only used coldfusion for queries before never needed structs or any object
Before all: excuse my english :) Ok, here we go - im developing mostly
Before you answer this I have never developed anything popular enough to attain high
Before I start, I know there is this post and it doesn't answer my
Before I do this I figured I would ask if it was the best
Before moving on to use SVN, I used to manage my project by simply
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of

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.