timeframe strings

This commit is contained in:
AdrianLxM 2017-10-29 02:06:06 +02:00 committed by GitHub
parent 7d82870203
commit 9e8752b096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -146,4 +146,20 @@ public class DateUtil {
}
public static String timeFrameString(long timeInMillis){
long remainingTimeMinutes = timeInMillis/(1000*60);
long remainingTimeHours = remainingTimeMinutes/60;
remainingTimeMinutes = remainingTimeMinutes%60;
return "(" + ((remainingTimeHours >0)?(remainingTimeHours + "h "):"") + remainingTimeMinutes + "')";
}
public static String sinceString(long timestamp){
return timeFrameString(System.currentTimeMillis()-timestamp);
}
public static String untilString(long timestamp){
return timeFrameString(timestamp- System.currentTimeMillis());
}
}