@@ -0,0 +1,2841 @@
+package tars.ui.formatter;%0A%0Aimport java.time.LocalDateTime;%0Aimport java.time.format.DateTimeFormatter;%0A%0A/**%0A * Container for formatting dates%0A * %0A * @@author A0139924W%0A */%0Apublic class DateFormatter %7B%0A    private static final DateTimeFormatter DATE_FORMAT =%0A            DateTimeFormatter.ofPattern(%22E, MMM dd%22);%0A    private static final DateTimeFormatter TIME_FORMAT =%0A            DateTimeFormatter.ofPattern(%22hh:mm a%22);%0A    private static final DateTimeFormatter NORMAL_DATETIME_FORMAT =%0A            DateTimeFormatter.ofPattern(%22E, MMM dd hh:mm a%22);%0A    private static final DateTimeFormatter NORMAL_DATE_DIFF_YEAR_FORMAT =%0A            DateTimeFormatter.ofPattern(%22E, MMM dd yyyy hh:mm a%22);%0A%0A    private static final String TODAY_PREFIX_TEXT = %22Today at %22;%0A    private static final String TOMORROW_PREFIX_TEXT = %22Tomorrow at %22;%0A%0A    public static String generateSingleDateFormat(LocalDateTime firstDate) %7B%0A        if (isToday(firstDate)) %7B%0A            return TODAY_PREFIX_TEXT + TIME_FORMAT.format(firstDate);%0A        %7D else if (isTomorrow(firstDate)) %7B%0A            return TOMORROW_PREFIX_TEXT + TIME_FORMAT.format(firstDate);%0A        %7D else %7B%0A            return NORMAL_DATETIME_FORMAT.format(firstDate);%0A        %7D%0A    %7D%0A%0A    public static String generateDateRangeFormat(LocalDateTime firstDate,%0A            LocalDateTime secondDate) %7B%0A        if (isSameDay(firstDate, secondDate)) %7B%0A            return DATE_FORMAT.format(firstDate) + %22 %22%0A                    + TIME_FORMAT.format(firstDate) + %22 - %22%0A                    + TIME_FORMAT.format(secondDate);%0A        %7D else if (isSameYear(firstDate, secondDate)) %7B%0A            return NORMAL_DATETIME_FORMAT.format(firstDate) + %22 - %22%0A                    + NORMAL_DATETIME_FORMAT.format(secondDate);%0A        %7D else %7B%0A            return NORMAL_DATE_DIFF_YEAR_FORMAT.format(firstDate) + %22 - %22%0A                    + NORMAL_DATE_DIFF_YEAR_FORMAT.format(secondDate);%0A        %7D%0A    %7D%0A%0A    private static boolean isToday(LocalDateTime firstDate) %7B%0A        return isSameDay(firstDate, LocalDateTime.now());%0A    %7D%0A%0A    private static boolean isTomorrow(LocalDateTime firstDate) %7B%0A        return isSameDay(firstDate, LocalDateTime.now().plusDays(1));%0A    %7D%0A%0A    private static boolean isSameDay(LocalDateTime firstDate,%0A            LocalDateTime secondDate) %7B%0A        DateTimeFormatter sameDayDateFormat =%0A                DateTimeFormatter.ofPattern(%22ddMMyyyy%22);%0A        return sameDayDateFormat.format(firstDate)%0A                .equals(sameDayDateFormat.format(secondDate));%0A    %7D%0A%0A    private static boolean isSameYear(LocalDateTime firstDate,%0A            LocalDateTime secondDate) %7B%0A        DateTimeFormatter sameDayDateFormat =%0A                DateTimeFormatter.ofPattern(%22yyyy%22);%0A        return sameDayDateFormat.format(firstDate)%0A                .equals(sameDayDateFormat.format(secondDate));%0A    %7D%0A%7D%0A

Create new date formatter class