Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with converting milliseconds to hours and minutes
    primarykey
    data
    text
    <p>Hi everyone , I am working on an app that has an alarm clock. When the user sets the alarm , the app should tell the user how long till the alarm goes off. </p> <p>I am using simpleDateFormater to get the the milliseconds into the right format. The alarm goes off correctly at the set time , but in the formatted time i am always getting an extra 11 hours.</p> <p>FOr example. if the time now is 1:00 am and I am setting the alarm for 1:10 am . I get the message saying the alarm is set for 11 hrs and 10 mins instead of just 10 minutes.The alarm goes off correctly at 1:10 am. </p> <p>I am attaching the relevant code , let me know if you need to see any more of the code.</p> <pre><code>long current = System.currentTimeMillis(); long time_left = set_time-current; // set_time is the time the alarm should go off , and it is set else where in the activity. String datePattern = "h ' hours and' mm ' minutes'"; SimpleDateFormat formatter = new SimpleDateFormat(datePattern); String timeLeft_string = formatter.format(time_left); Toast.makeText(getBaseContext(), "Alarm set for"+timeLeft_string, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getBaseContext(), AlarmReceiver.class); intent.putExtra("id", mRowId); PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), mRowId_int, intent, 0); AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, set_time, pendingIntent); </code></pre> <p>Here are my questions : 1. where is the 11 hours coming from ? 2. how do I get rid of it ?</p> <p>Thanks for taking the time to read this and for any help that you can give.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload