I created a custom TimePicker
preference for my Android Wear watch face. The user selects a time and it returns the current time in milliseconds. The code for this can be found on my GitHub repo.
I don't think there is anything wrong with what I'm doing in that class--but maybe I am. Anyways, I then go to read the values like so:
final long nightModeStartTimeMillis = prefs.getLong("settings_night_mode_start_time",
Long.valueOf(getString(R.string.settings_night_mode_default_start_time)));
final long nightModeEndTimeMillis = prefs.getLong("settings_night_mode_end_time",
Long.valueOf(getString(R.string.settings_night_mode_default_end_time)));
My problem is that I want to use these times to determine if the current time is between them. However, I can't quite figure out how to handle the date. My defaultValue
for the start time TimePreference
is 1483318830000
(Sun Jan 01 20:00:30 EST 2017). I've been trying the code found from this answer, but when it comes to comparing, I think I'll never have the current time be between the default values since the date for the milliseconds never changes--only the hour and minutes.
This is my current attempt--which doesn't work
Is there some way around this that is simpler than I'm making it? Kinda confused with all of this.