Skip to content

Commit ca33637

Browse files
committed
Fixes relative time formatting issue for dates in future
All variations of getRelativeTimeSpanString() now properly handle dates that are in the future. Prior, the version used by getRelativeDateTimeString() would occasionally show the time instead of a date when the future date was the same weekday as the current weekday. This resulted in the time output being duplicated, eg.: "11:23, 11:23" Change-Id: If20972a6942cce792fa233437f94dedfb71379f3 Signed-off-by: Steve Pomeroy <steve@staticfree.info>
1 parent 13ab2c9 commit ca33637

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/java/android/text/format/DateUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ public static CharSequence getRelativeTimeSpanString(Context c, long millis,
16181618

16191619
String result;
16201620
long now = System.currentTimeMillis();
1621-
long span = now - millis;
1621+
long span = Math.abs(now - millis);
16221622

16231623
synchronized (DateUtils.class) {
16241624
if (sNowTime == null) {

0 commit comments

Comments
 (0)