diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-26 03:27:55 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-26 03:27:55 +0100 |
commit | 898b0ca8c485888e06e2b5b1c798eebce1a6dabc (patch) | |
tree | f737883fd44da0270ed5ae0f76560d202d55ff24 /src/de/gultsch/chat/utils/Beautifier.java | |
parent | 665ef7511f5dcccb349228baa2aa6f02281d3c07 (diff) |
chat bubbles. yeah
Diffstat (limited to 'src/de/gultsch/chat/utils/Beautifier.java')
-rw-r--r-- | src/de/gultsch/chat/utils/Beautifier.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/de/gultsch/chat/utils/Beautifier.java b/src/de/gultsch/chat/utils/Beautifier.java new file mode 100644 index 000000000..43b7acc2c --- /dev/null +++ b/src/de/gultsch/chat/utils/Beautifier.java @@ -0,0 +1,25 @@ +package de.gultsch.chat.utils; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class Beautifier { + public static String readableTimeDifference(long time) { + if (time==0) { + return "just now"; + } + Date date = new Date(time); + long difference = (System.currentTimeMillis() - time) / 1000; + if (difference<60) { + return "just now"; + } else if (difference<60*10) { + return difference / 60 + " min ago"; + } else if (difference<60*60*24) { + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); + return sdf.format(date); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("M/D"); + return sdf.format(date); + } + } +} |