Issue
I am trying to convert given number of minutes into milliseconds.
For eg: 15mins or 20mins or 44mins should be converted to milliseconds programmatically.
I tried the below:
Calendar alarmCalendar = Calendar.getInstance();
alarmCalendar.set(Calendar.MINUTE,15);
long alarmTime = alarmCalendar.getTimeInMillis();
Log.e("Milli", "seconds"+alarmTime);
This doesn't give the right value? What is the best way to convert this?
Solution
TimeUnit.MINUTES.toMillis(yourMinutes)
see TimeUnit
javadoc (android)
Answered By - user180100
Answer Checked By - Katrina (JavaFixing Volunteer)