I'm currently changing some code from Joda-Time to use Three-Ten Android Backport.
All of the following methods take in a long
as param and return a long
Getting the end and start of the week with JodaTime was straight forward with Joda-Time:
LocalDate(long time).dayOfWeek().withMaximumValue()
LocalDate(long time).dayOfWeek().withMinimumValue()
The same issue is present with end and start of a day, with Joda-Time:
DateTime(long time).withTimeAtStartOfDay().getMillis() + DateUtils.DAY_IN_MILLIS - 1
DateTime(long time).withTimeAtStartOfDay().getMillis()
However I don't understand how to use threeTenAbp in this way.
One thought for end and start of days:
END OF DAY:
LocalDateTime dt = DateTimeUtils.toLocalDateTime(new Timestamp(time));
ZonedDateTime zdt = ZonedDateTime.of(dt, ZoneId.systemDefault());
return zdt.with(LocalTime.MAX).toEpochSecond();
START OF DAY:
LocalDateTime dt = DateTimeUtils.toLocalDateTime(new Timestamp(long time));
ZonedDateTime zdt = ZonedDateTime.of(dt, ZoneId.systemDefault());
return zdt.toLocalDate().atStartOfDay(ZoneId.systemDefault()).toEpochSecond();
This seems pretty convoluted and doesn't really provide me with any clues on how to obtain and time for the start and end of the week respective to the long time
passed in to the functions.