In my Android application, I have 3 spinners for Hour/Minute/ and PM or AM. I’d like to add 7.5 hours in that to get the needed time for the user to sleep. This android application of mine is a calculator of a user’s sleep. For example, I’d like to wake up at 7:00 AM. BY 11:15 PM you should now be sleeping. Please give me some directions on how to do this. I’m in dire need of help. Thanks. Appreciate your help.
like this:
/**
* Get sleeping times corresponding to a local time
*
* @param wakingTime
* time to wake up !
* @return list of times one should go to bed to
*/
public static Set<Date> getSleepingTimes(Date wakingTime) {
Set<Date> result = new TreeSet<Date>();
Calendar calendar = Calendar.getInstance();
calendar.setTime( wakingTime );
calendar.add( Calendar.MINUTE, -14 );
calendar.add( Calendar.MINUTE, -( 2 * 90 ) );
for ( int i = 3; i <= 6; i++ ) {
calendar.add( Calendar.MINUTE, -90 );
result.add( calendar.getTime() );
}
return result;
} // end of getSleepingTimes method
but better not to hard code the 7.5 hours.
use like this: