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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:00:00+00:00 2026-05-18T20:00:00+00:00

Okay, So I’m working on having an alarm that gives a notification at, lets

  • 0

Okay, So I’m working on having an alarm that gives a notification at, lets say 3:00 PM daily, but I want this to be selectable by the user, between AM/PM, and Hours/Min freely changeable. I will probably use a TimePicker, and this is my code I have so far:

    public void startAlarm() {


            Intent intent = new Intent(currentDay.this, AlarmReceiver.class);
            PendingIntent sender = PendingIntent.getBroadcast(currentDay.this,0, intent,0);

            long firstTime = SystemClock.elapsedRealtime();
            firstTime += 15*1000;


            AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
            am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime,AlarmManager.INTERVAL_DAY, sender);


        }

So, I figure I’m going to be using something along the lines of:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 19);
cal.set(Calendar.MINUTE, 45);

and then using

cal.getTimeInMillis()

But this doesn’t work, any ideas? Thanks!

EDIT: So, long story short, I know how to get the current time, then add lets say 15 seconds to it, but I want to have a definite time that WORKS for example 5:14 PM, and everything I’ve tried doesn’t 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-18T20:00:00+00:00Added an answer on May 18, 2026 at 8:00 pm

    As far as I can tell you are getting a Calendar instance with the current date/time and then you are adding 19 hours and 45 minutes to it, NOT setting the time of the Calendar instance explicitly to 19:45. Is that what you are meaning to do? You need to use the Calendar set() method to set an explicit time.

    From the API reference for Calendar

    Calendar’s getInstance method returns a calendar whose locale is based on system settings and whose time fields have been initialized with the current date and time:

        Calendar rightNow = Calendar.getInstance()
    
    public abstract void add (int field, int value)
    
    Since: API Level 1
    Adds the specified amount to a Calendar field.
    Parameters
        field   the Calendar field to modify.
        value   the amount to add to the field.
        Throws IllegalArgumentException if field is DST_OFFSET or ZONE_OFFSET.
    

    EDIT: To convert local time to UTC…

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 19);
    cal.set(Calendar.MINUTE, 45);
    int offset = cal.getTimeZone().getOffset(cal.getTimeInMillis());
    firstTime = cal.getTimeInMillis() + offset;
    

    NOTE: I haven’t tried the above and there may be an easier way but it should work. It’s hard for me to test stuff like this as my timezone is GMT/UTC.

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

Sidebar

Related Questions

Okay so im working on this php image upload system but for some reason
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, so this is a long long shot but here it goes... When IE
Okay so my question is this. Say I have a simple C++ code: #include
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay, so I've known about this for like 600 years now, but I've only
Okay I got some good advice for Mobile Detection but still having an issue
Okay this is a bit of a noobish question, but I ran across this
Okay, so this seems simple, but I can't think of a straightforward solution; Basically
Okay, so I want to make a menu that expands down at the current

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.