Class TimeHelper


  • public class TimeHelper
    extends Object
    • Field Detail

      • NO_DATE

        public static final Date NO_DATE
    • Constructor Detail

      • TimeHelper

        public TimeHelper()
    • Method Detail

      • toStartWeek

        public static Date toStartWeek​(Date date)
        set the date at the first day of the week.o
        Parameters:
        date -
        Returns:
      • isAfterOrEqualForDay

        public static boolean isAfterOrEqualForDay​(Date date,
                                                   Date ref)
        check if date is after other date, if the day is the same it is ok.
      • isAfterForDay

        public static boolean isAfterForDay​(Date date,
                                            Date ref)
        check if date is after other date.
      • isBeforeOrEqualForDay

        public static boolean isBeforeOrEqualForDay​(Date date,
                                                    Date ref)
        check if date is after other date, if the day is the same it is ok.
      • isBeforeForDay

        public static boolean isBeforeForDay​(Date date,
                                             Date ref)
        check if date is after other date, if the day is the same it is ok.
      • isEqualForDay

        public static boolean isEqualForDay​(Date date,
                                            Date ref)
        check if date is after other date, if the day is the same it is ok.
      • betweenInDay

        public static boolean betweenInDay​(Date date,
                                           Date start,
                                           Date end)
        check id a date in between two other date, but date in range.
        Parameters:
        date -
        start -
        end -
        Returns:
      • getCalendar

        public static Calendar getCalendar​(Date date)
      • convertRemoveAfterMinutes

        public static Calendar convertRemoveAfterMinutes​(Calendar cal)
      • convertRemoveAfterHour

        public static Calendar convertRemoveAfterHour​(Calendar cal)
      • convertRemoveAfterDay

        public static Calendar convertRemoveAfterDay​(Calendar cal)
      • convertRemoveAfterMonth

        public static Calendar convertRemoveAfterMonth​(Calendar cal)
      • getDaysDistance

        public static int getDaysDistance​(Date date1,
                                          Date date2)
        get the distance between 2 dates in day
        Parameters:
        date1 -
        date2 -
        Returns:
      • main

        public static void main​(String[] args)
      • getDaysDistance

        public static long getDaysDistance​(LocalDate date1,
                                           LocalDate date2)
        get the distance between 2 dates in day
        Parameters:
        date1 -
        date2 -
        Returns:
      • getAge

        public static int getAge​(Date born)
      • convertToLocalDateViaInstant

        public static LocalDate convertToLocalDateViaInstant​(Date dateToConvert)
      • convertToLocalDateTimeViaInstant

        public static LocalDateTime convertToLocalDateTimeViaInstant​(Date dateToConvert)