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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:36:55+00:00 2026-06-07T14:36:55+00:00

So what I am trying to do is to make an alarm clock. I

  • 0

So what I am trying to do is to make an alarm clock. I am having trouble getting the current time and get the timepicker’s time to compare them. If you could help me out a bit just getting the timepicker’s time and the current time in the same kind of measurement would be great.

Thanks a ton =)
Here is my code:

public class AlarmlockActivity extends Activity implements OnClickListener {
    TimePicker tp;
    Button set;
    long currentTime;
    long alarmTime;
    long alarmHourmil;
    DigitalClock dc;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    tp = (TimePicker) findViewById(R.id.tpAlarmTime);
    set = (Button) findViewById(R.id.bSet);
    dc = (DigitalClock) findViewById(R.id.digitalClock1);
    currentTime = System.currentTimeMillis();
    set.setOnClickListener(this);
}

public void onClick(View v) {
    switch(v.getId()){
    case R.id.bSet:
        break;
    }
}
 }
  • 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-06-07T14:36:57+00:00Added an answer on June 7, 2026 at 2:36 pm

    I assume that extracting hour and minutes from current time is enough to get “timepicker’s time and the current time in the same kind of measurement.

    If that’s the case you can use Calendar class (see docs) to extract info about current time. Here’s an example code that assumes, you want to use default Locale and TimeZone, if that’s not the case please refer to other Calendar.getInstance() methods.

    // Get Calendar object with current date and time (assumes default Locale and TimeZone).
    Calendar calendar = Calendar.getInstance()
    
    // Retrieve info about current time.
    int hour = calendar.get(Calendar.HOUR);
    int minute = calendar.get(Calendar.MINUTE);
    
    // Compare with values selected in TimePicker
    if (tp.getCurrentHour().intValue() == hour) { // similar applies to 'minute'
        // do whatever you want
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an alarm clock in which you can set multiple times.
I just went through trying to make an alarm clock app with local notifications
I am trying to make alarm ring when the time of calendar event is
I am trying to make an alarm application that will take ‘n’ number of
I am trying to make a simple alarm. in this code portion a take
I'm trying to make alarm in my app. I made UILocalNotification and it works
trying to make 5 curl childs for curl handler and defining them, but can't
I am trying make a clock. The hour is a string. I want to
I am trying make a request and get response from server. Here is my
I am trying to make an alarm that would ring at specified n number

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.