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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:41:40+00:00 2026-05-14T04:41:40+00:00

I’m trying to figure out how to enforce a 5 minute per post/action rule.

  • 0

I’m trying to figure out how to enforce a 5 minute per post/action rule.

I’m developing a web application with Wicket in Java and I’ve got a session class which I was planning on using to keep track of these timers on a per-user basis. I wasn’t planning on storing the timestamp in a database.

I’ve got the method below in my session class, and now I’m trying to figure out how to go about storing and checking that there’s a 5 minute difference between the last time the user posted and the current time.

If, lets say java.util.Date, would be suitable for this, how do I get the difference between two of these, in minutes.

public boolean isAllowedToPost() {  
    if(null OR has 5 minutes passed since last post) {  
        // set the new timestamp      
        return true;    
    }  
    else   
    {   
        return false;  
    }  
}
  • 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-14T04:41:41+00:00Added an answer on May 14, 2026 at 4:41 am

    The most robust way would be storing the timestamp in a database, since the client could simply logout/login or trash the session (delete cookie or restart webbrowser) to obtain a new session.

    If you insist in storing it in session at any way, then one of the ways would be setting the timestamp during post() and use it as comparision material in isAllowedToPost(). You can obtain the current timestamp by System#currentTimeMillis(). No need for java.util.Date.

    Kickoff example (assuming that this whole bean is session scoped):

    private static final long MAX_WAIT_FOR_POST = 300000L; // ..ms = 5 minutes.
    private long lastPost; // Defaults to 0 anyway.
    
    public void post() {
        lastPost = System.currentTimeMillis();
        // ...
    }
    
    public boolean isAllowedToPost() {
        return (lastPost + MAX_WAIT_FOR_POST) < System.currentTimeMillis();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.