0

Okay, so I am developing a bus app that gives you the next bus on your station. On one activity I have all the buses and their times, and I just want to highlight the next bus, using the clock from the phone of the user? Is this possible?

Mehmet K
  • 2,805
  • 1
  • 23
  • 35
angelazaff
  • 23
  • 4
  • take the time from the clock and then match it with all the bus timing using switch case and highlight the next bus timing. Use `Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("dd:MMMM:yyyy HH:mm:ss a"); String strDate = sdf.format(c.getTime()); ` – knownUnknown Mar 23 '17 at 12:38

1 Answers1

0

If you want the current time, you don't need the device clock, you can get through simple code. Just doing Calendar.getInstance() gives you a new calendar object for the current time that takes timezone into account. From this object you can get the day, hour, minutes...

This post explains in detail how to get/use the current time

Community
  • 1
  • 1
Mehmet K
  • 2,805
  • 1
  • 23
  • 35