I need to show a red dot inside a recyclerView when a list item business working and red when it does not.
I use databinding, API 24, with the ability to use Java 8 calls (particularly API 26 new java.Time and its LocalTime
and LocalDate
).
//Get local date way 1
var day: String = LocalDate.now().dayOfWeek.name
var time: String = LocalTime.now().toString()//.hour.toString()
//Get local date way 2
val calendar = Calendar.getInstance()
val dateInfo = DateFormat.getDateInstance(DateFormat.FULL).format(calendar.time)
//Get local date way 3
var date = Date()
I receive working hours from the server in the following format:
"schedule_1": "09:00 22:00",
"schedule_2": "09:00 22:00",
"schedule_3": "09:00 22:00",
"schedule_4": "09:00 22:00",
"schedule_5": "09:00 22:00",
"schedule_6": "09:00 17:00",
"schedule_7": "",
Each schedule is the day of the week, so I need to check if it is today.
Most of the questions on Stack Overflow compare two timestamps or two dates and they are all one-pagers, but I want time inside working hours one-liner.