I want to use long value I got from android API that return me dates as longs, represented as milliseconds since Epoch.
I need to use methods like isBefore() plusDays() isAfter()
Cursor managedCursor = getContentResolver().query(CallLog.Calls.CONTENT_URI,
new String[]{"number", "type", "date", "duration", "name"},
null, null, strOrder);
In java I can use LocalDate and LocalTime classes to handle this, unfortunately these classes don't exist on android so what classes available on android similar to localdate and localtime?
LocalDate – represents a date (year, month, day) LocalDateTime – same as LocalDate, but includes time with nanosecond precision.
LocalTime is an immutable class whose instance represents a time in the human readable format. It's default format is hh:mm:ss. zzz.
The withDayOfMonth() method of LocalDate class in Java returns a copy of this LocalDate with the day-of-month altered.
now() now() method of a LocalDateTime class used to obtain the current date-time from the system clock in the default time-zone. This method will return LocalDateTime based on system clock with default time-zone to obtain the current date-time.
https://github.com/dlew/joda-time-android
This is the library that most use for time in Android. A bit heavy on size, but if that's not an issue then it's way better than using utils Android gives you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With