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

  • Home
  • SEARCH
  • 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 6167209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:28:17+00:00 2026-05-23T22:28:17+00:00

Basically, in the method below, for reasons unknown to myself or my team, the

  • 0

Basically, in the method below, for reasons unknown to myself or my team, the outermost for loop will does not execute any code on the first itteration. What I mean by that is, on the first round of execution it goes to the end of the loop and back to the beginning without executing any code. I have confirmed this by debugging through eclipse. However, the loop executes as normal after this first cycle.

What this method is doing is pulling days from a database, putting them into weeks, and putting those weeks into a month. but, because of this weird “glitch” the first cycle does not pull any days and subsequently does not create a week to be put in the month BUT it does execute the counter of the loop which basically leaves the data out off sync with the loop:

1st run: nothing
2nd run: 1st week
3rd run: 2nd week
...
last run: SECOND LAST WEEK

so, everythime the method returns the month, the last week is always missing.

BUT what is really WEIRD is that this loop used to work perfectly. In fact, I am 99.9999% positive that it was functioning before I went home last night and then when I came in today it suddenly developed this error. The only reason that I have that tiny amount of doubt is that IT MAKES ABSOLUTELY NO SENSE FOR THAT TO BE THE CASE! So realistically I must have accidently changed something and not realised it. If anyone could thake a look at this and suggest a possible cause that would be very much appreciated.

Thanks

private Month translateToFormData(List<WeekEntry> weekList, TimeSheetForm timeSheetForm) {
    int monthOfInterest = timeSheetForm.getMonth().getMonthOfYear();
    // month to be returned
    Month month = new Month();
    // Calendars to translate from Date to Calendar
    // loop through weekList
    for (WeekEntry weekEntry : weekList) {
        // week value to be filled
        Week week = new Week();
        Calendar calWeekBeginning = new GregorianCalendar();
        // set the date of the first day in "week" (Sunday)
        calWeekBeginning.setTime(weekEntry.getWeekBeginning());
        week.setWeekBeginning(calWeekBeginning);
        Set<DayEntry> daySet = weekEntry.getDays();
        // Loop through days of the weekList items
        for (DayEntry dayEntry : daySet) {
            // day value to be filled
            Day day = new Day();
            Calendar calDateOfDay = new GregorianCalendar();
            // set the date of the day
            calDateOfDay.setTime(dayEntry.getDateOfDay());
            day.setDate(calDateOfDay);
            // set the hours of the day
            day.setWorkHours(dayEntry.getHours());
            // define the day type
            if (calDateOfDay.get(Calendar.MONTH) != monthOfInterest) {
                day.setType(DayType.BLANK_DAY);
            } else if (calDateOfDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calDateOfDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                day.setType(DayType.WEEK_END);
            } else {
                day.setType(DayType.WEEK_DAY);
            }
            // add the day to the week
            week.addDay(day);
        }
        // add the week to the month
        month.addWeek(week);
    }
    return 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-23T22:28:18+00:00Added an answer on May 23, 2026 at 10:28 pm

    Found the problem, it was me being a herpaderp! thanks for your suggestions

    Edit at the request of chris…

    As it turned out, it was to do with how I was saving the objects to the DB. It was putting a timestamp on each row as well at the date and this was causing it to not retrieve the first element if the code ran at an earlier time of day then when the entries were initially saved. I don’t know why it was only the first cycle of the loop that was affected but once I set it to save items without recording the time of day, it runs without any problems.

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

Sidebar

Related Questions

I'm trying to write a method that will return a Hibernate object based on
I have an error for this method below def mymethod cat = Cat.find_by_cat_id_and_animal_id_and_name(catid, haustierid,
This is hard to explain, but I will do my best: I am building
I am basically walking the LDAP tree in Active Directory. At each level I
I am messing around with jQuery's AJAX functions and was trying to simulate how
I am trying to create a 2D platformer (Mario-type) game and I am some
I've been looking into how to best organise my libraries/classes recently and I'm yet
I am running running a script which moves an uploaded file with move_uploaded_file() .
I am writing a script using jQuery to add multiple control boxes(divs) to a
I'm working on a site where users can describe a physical object using (amongst

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.