Join Carlos Rivas for an in-depth discussion in this video Calculate the seconds passed, part of Code Clinic: Java.
- [Instructor] Let's now create our API service method.…We need to do two important things here.…Number one: we need a way to convert the current time…into the number of seconds that have passed since midnight.…This will be our index to access our data arrays.…And it will help us simulate that the data…is being generated right now in real time.…For our number two task we need to populate…a map data structure with the values that will be…passed in json format to the callers of our API.…
Let's take care of the first part right now.…First, we're going to create a date time structure,…which will hold the current time.…We do this by calling the now method.…Next we need to figure out the midnight value…for that particular day.…We do this by taking our current value of now…and dropping everything related to time…and just keeping the date.…That will zero out all the time values.…
We do this by calling the truncated to method…of the zone date time class.…Now we're going to specify the unit to be in days.…Again, this will drop everything time related…
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.