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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:41:33+00:00 2026-05-18T02:41:33+00:00

In order to run a background service I want to scedule a thread for

  • 0

In order to run a background service I want to scedule a thread for running daily at 1am. How can I get this date in java?

Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, HOUR_OF_EXECUTION);
Date date = cal.getTime();

did not work.

  • 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-18T02:41:33+00:00Added an answer on May 18, 2026 at 2:41 am

    You should go for Quartz.

    • Here is some sample code.

    OR

    Timer timer = new Timer();
    final Callable c = callable;
    TimerTask task = new TimerTask() {
        public void run() {
                c.call();
        }
    }
    t.scheduleAtFixedRate(task, firstExecuteDate, 86400000); // every day  
    

    Give firstExecuteDate accordingly and your thing has done, more over to get next execute – now

    To get next date for time 1 pm.

    Calendar cal  = Calendar.getInstance();
    Calendar calAtOne  = Calendar.getInstance();
    calAtOne.set(Calendar.HOUR_OF_DAY,13);
    calAtOne.set(Calendar.MINUTE,00);
    calAtOne.set(Calendar.SECOND,00);
    
    if(calAtOne.after(cal)){
        return calAtOne;
    }else{
        cal.add(Calendar.DATE,1);
        cal.set(Calendar.HOUR_OF_DAY,13);
        cal.set(Calendar.MINUTE,00);
        cal.set(Calendar.SECOND,00);
        return cal;
    }
    

    Then subtract currentMillis - (nextExecDate returned By above code)

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

Sidebar

Related Questions

I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
I am attempting to use an Intent Service to run in the background to
I am using background threads to run intense search processes in order to allow
I am looking for an app that would run a background service that would
The purpose of this application is to run in the background 24/7 and lock
I am trying to run this activity in order to query a database for
i have a few developers who constantly put If null checks For example: Run(Order
Is there any way to set order by clause in HQL by run time.
I'm using the android-maven-plugin 3.2.0 and run the following in order to install and
I'm using python-spidermonkey to run JavaScript code. In order to pass objects (instead 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.