/** * returns in the form " X hours and Y minutes from now/ago" or " RIGHT NOW!" it returns nothing * if the difference is > 1 day */ private String getTimeDifference(int mins) { if (Math.abs(mins) > 60 * 24) { return ""; } boolean neg = mins < 0; mins = Math.abs(mins); if (mins < 5) { return " ****THAT'S RIGHT NOW!****"; } String ret = " ("; int hrs = mins / 60; mins = mins % 60; if (hrs > 0) { ret = ret + hrs + " hours and "; } ret = ret + mins + " minutes "; if (neg) { ret = ret + "ago)"; } else ret = ret + "from now)"; return ret; }
private String getRandomArrayValue(String[] arr) { return arr[(int) (arr.length * Math.random())]; }