src/main/java/de/dennisguse/opentracks/util/StringUtils.java
public static String formatDateTodayRelative(Context context, OffsetDateTime odt) {
        LocalDate today = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()).toLocalDate();
        LocalDate ld = odt.toLocalDate();
        long daysBetween = DAYS.between(ld, today);

        if (daysBetween == 0) {
            // Today
            return context.getString(R.string.generic_today);
        } else if (daysBetween == 1) {
            // Yesterday
            return context.getString(R.string.generic_yesterday);
        } else if (daysBetween < 7) {
            // Name of the week day
            return ld.format(DateTimeFormatter.ofPattern("EEEE"));
        } else if (today.getYear() == ld.getYear()) {
            // Short date without year
            return ld.format(DateTimeFormatter.ofPattern("d MMM"));
        } else {
            // Short date with year
            return ld.format(DateTimeFormatter.ofPattern("d MMM y"));
        }
    }
/**
     * Formats the date relative to today date.
     */
Formats the date relative to today date.
Formats the date relative to today date .
public static String formatDateTodayRelative(Context context, OffsetDateTime odt) {
        LocalDate today = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()).toLocalDate();
        LocalDate ld = odt.toLocalDate();
        long daysBetween = DAYS.between(ld, today);
        if (daysBetween == 0) {
            return context.getString(R.string.generic_today);
        } else if (daysBetween == 1) {
            return context.getString(R.string.generic_yesterday);
        } else if (daysBetween < 7) {
            return ld.format(DateTimeFormatter.ofPattern("EEEE"));
        } else if (today.getYear() == ld.getYear()) {
            return ld.format(DateTimeFormatter.ofPattern("d MMM"));
        } else {
            return ld.format(DateTimeFormatter.ofPattern("d MMM y"));
        }
    }
public static String formatDateTodayRelative ( Context context , OffsetDateTime odt ) { LocalDate today = LocalDateTime . ofInstant ( Instant . now ( ) , ZoneId . systemDefault ( ) ) . toLocalDate ( ) ; LocalDate ld = odt . toLocalDate ( ) ; long daysBetween = DAYS . between ( ld , today ) ; if ( daysBetween == 0 ) { return context . getString ( R . string . generic_today ) ; } else if ( daysBetween == 1 ) { return context . getString ( R . string . generic_yesterday ) ; } else if ( daysBetween < 7 ) { return ld . format ( DateTimeFormatter . ofPattern ( "EEEE" ) ) ; } else if ( today . getYear ( ) == ld . getYear ( ) ) { return ld . format ( DateTimeFormatter . ofPattern ( "d MMM" ) ) ; } else { return ld . format ( DateTimeFormatter . ofPattern ( "d MMM y" ) ) ; } }
Formats the date relative to today date.
Formats the date relative to today date .
// Today // Yesterday // Name of the week day // Short date without year // Short date with year