Skip to content

Commit

Permalink
Actually check if Instants are on same day
Browse files Browse the repository at this point in the history
This fixes the bug introduced by fixing a bug in 8b6b20a.

This StackOverflow answer pointed to the proper information about how
to compare two Instants as Dates.

http://stackoverflow.com/a/27968194/1798762
  • Loading branch information
macklinu committed May 20, 2016
1 parent 23d0178 commit 1c39445
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Locale;
import org.threeten.bp.Instant;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneOffset;
import org.threeten.bp.ZonedDateTime;
Expand All @@ -18,7 +19,9 @@ public static Instant fromEstString(String text) {
}

public static boolean areOnSameDay(Instant left, Instant right) {
return ChronoUnit.DAYS.between(left, right) == 0;
LocalDate leftOffset = offset(left).toLocalDate();
LocalDate rightOffset = offset(right).toLocalDate();
return ChronoUnit.DAYS.between(leftOffset, rightOffset) == 0;
}

public static String dayTimeString(Instant instant) {
Expand Down

0 comments on commit 1c39445

Please sign in to comment.