@@ -0,0 +1,3135 @@
+package uk.gov.hmrc.mobile.util;%0A%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Calendar;%0Aimport java.util.Date;%0Aimport java.util.GregorianCalendar;%0Aimport java.util.Locale;%0Aimport java.util.Map;%0A%0Aimport myapp.R;%0A%0Apublic class DateUtil %7B%0A%0A    final static SimpleDateFormat HMRC_NEWS_DATE_FORMAT = new SimpleDateFormat(%22d MMM yyyy%22);%0A    final static SimpleDateFormat INBOX_MESSAGE_FORMAT  = new SimpleDateFormat(%22M/d/yy%22);%0A    final static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat(%22h:mm a%22);%0A%0A    // static PrettyTime p = new PrettyTime();%0A%0A    public static String getTimeString(Date date) %7B%0A%0A        String dateStr = HMRC_NEWS_DATE_FORMAT.format(date);%0A%0A        return dateStr;%0A    %7D%0A%0A    public static String getTimeString(String prefix, Date date) %7B%0A%0A        String dateStr = DateUtil.getTimeString(date);%0A%0A        dateStr = prefix + dateStr;%0A%0A        return dateStr;%0A    %7D%0A%0A    public static String getInboxTimeSpanString(Map%3CInteger, String%3E resIdToStringMap, Date now, Date before) %7B%0A%0A        return DateUtil.getTimeSpanString(resIdToStringMap, now, before);%0A    %7D%0A%0A    public static String getMessageTimeSpanString(Map%3CInteger, String%3E resIdToStringMap, Date now, Date before) %7B%0A%0A        String sent = resIdToStringMap.get(R.string.sent);%0A        String at   = resIdToStringMap.get(R.string.at);%0A%0A        String result = DateUtil.getTimeSpanString(resIdToStringMap, now, before);%0A%0A        String timeStr = TIME_FORMAT.format(before);%0A        timeStr = timeStr.toLowerCase(Locale.UK);%0A%0A        StringBuffer sb = new StringBuffer();%0A        sb.append(sent);%0A        sb.append(%22 %22);%0A        sb.append(result);%0A        sb.append(%22 %22);%0A        sb.append(at);%0A        sb.append(%22 %22);%0A        sb.append(timeStr);%0A%0A        result = sb.toString();%0A%0A        return result;%0A    %7D%0A%0A    private static String getTimeSpanString(Map%3CInteger, String%3E resIdToStringMap, Date now, Date before) %7B%0A%0A        String today        = resIdToStringMap.get(R.string.today);%0A        String yesterday    = resIdToStringMap.get(R.string.yesterday);%0A%0A        String result = null;%0A%0A        int days = DateUtil.getDayCount(now, before);%0A        if (days == 0) %7B%0A            result = today;%0A        %7D%0A        else if (days == 1) %7B%0A            result = yesterday;%0A        %7D%0A        else if (days %3C 7) %7B%0A            Calendar cal = new GregorianCalendar();%0A            cal.setTime(before);%0A            SimpleDateFormat dateFormat = new SimpleDateFormat(%22EEEE%22);%0A            result = dateFormat.format(cal.getTime());%0A        %7D%0A        else  %7B%0A            result = INBOX_MESSAGE_FORMAT.format(before);%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    public static int getDayCount(Date now, Date before) %7B%0A        long diff = -1;%0A        try %7B%0A            //time is always 00:00:00 so rounding should help to ignore the missing hour when going from winter to summer time as well as the extra hour in the other direction%0A            diff = Math.round((now.getTime() - before.getTime()) / (double) 86400000);%0A        %7D catch (Exception e) %7B%0A            //handle the exception according to your own situation%0A        %7D%0A        return (int) diff;%0A    %7D%0A%7D%0A

Create DateUtil.java