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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:17:59+00:00 2026-05-18T04:17:59+00:00

Having trouble finding a solution for my situation here. Sorry if this has been

  • 0

Having trouble finding a solution for my situation here. Sorry if this has been answered before but I couldn’t find one that worked for me.

Problem: Trying to test if a user session has been active for longer than the timeout limit.

I am trying to use the session start time and the current system time and subtract them and if the result is greater than the timeout var – kill the session.

So:

 for (LogSession logSession : sessionLogList) {

                Calendar sessionStartTime = logSession.getStartTime();
                Calendar currentSysTime = Calendar.getInstance();
                currentSysTime.setTime(currentSysTime.getTime());
                Calendar activeTime = Calendar.getInstance();

                activeTime.setTime(sessionStartTime.getTime());
                activeTime.add(activeTime.getTime(), - currentSysTime.getTime());

                if ( activeTime.getTime() > timeoutLimit) {
                       // Do something
                }
}

I am obviously getting an error message on the activeTime.add line but am unsure of the needed approach here. Any help would be great thanks.

Timeout is currently set to 15 minutes but is a global variable that can be changed.

  • 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-18T04:17:59+00:00Added an answer on May 18, 2026 at 4:17 am

    Your sample seems to have a few errors in it but here is how I would go about it.

    Calendar sessionEndTime = logSession.getStartTime();
    sessionEndTime.add(Calendar.MINUTE, TIMEOUT_MINS);
    Calendar currentSysTime = Calendar.getInstance();
    if (currentSysTime.after(sessionEndTime)) {
    //do something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble finding a solution to this via google but I would have
No doubt elements of this question have been asked before, but I'm having trouble
I think this is a pretty simple question but I'm having trouble finding the
My app will be full screen, but I am having trouble finding the document
I'm having the trouble finding the wording, but is it possible to provide a
I'm a newbie to Silverlight and I'm having some trouble finding a solution to
I am having some trouble finding a solution for a system of equations using
I'm having trouble finding any examples of OpenGL ES 2 (C++) loading/displaying images. Been
I'm having trouble finding an open-source IDE with support for Git. Are there any
I'm looking to try out JRuby and JRuby on Rails. I'm having trouble finding

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.