Package core.helpers

Class DateHelper


  • public class DateHelper
    extends Object
    • Constructor Detail

      • DateHelper

        public DateHelper()
    • Method Detail

      • getTimestampMiliseconds

        public String getTimestampMiliseconds()
      • getCurrentTimeEpochSeconds

        public String getCurrentTimeEpochSeconds()
      • getCurrentTimeEpochMS

        public String getCurrentTimeEpochMS()
      • getTimeInstance

        public String getTimeInstance()
      • getTimestampSeconds

        public String getTimestampSeconds()
      • getTimeISOInstant

        public String getTimeISOInstant()
      • getCurrentTime

        public String getCurrentTime​(String format,
                                     String currentZone)
        get current time based on format and time zone output zone will be UTC
        Parameters:
        format -
        zone -
        Returns:
      • getCurrentTime

        public String getCurrentTime​(String format)
        get current time based on format
        Parameters:
        format -
        Returns:
      • getCurrentTime

        public String getCurrentTime​(Locale locale)
        get current time based on locale
        Parameters:
        format -
        Returns:
      • getCurrentTime

        public String getCurrentTime​(String format,
                                     String currentZone,
                                     String outputZone,
                                     Locale locale)
        get current time based on locale
        Parameters:
        format -
        Returns:
      • getTime

        public String getTime​(Instant time)
        get time string output time zone will be UTC by default
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(Instant time,
                              Locale locale)
        get time based on locale output time zone will be UTC by default
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(Instant time,
                              String format)
        get time based on format output time zone will be UTC by default
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(Instant time,
                              String format,
                              Locale locale)
        get time based on format output time zone will be UTC by default
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(Instant time,
                              String format,
                              String zone)
        get time based on format output time zone will be UTC by default
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(Instant time,
                              String format,
                              String zone,
                              Locale locale)
        get time based on format output time zone will be UTC by default
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(Instant time,
                              String format,
                              String currentZone,
                              String outputZone,
                              Locale locale)
        get time based on format
        Parameters:
        time -
        format -
        Returns:
      • getTime

        public String getTime​(String timeString,
                              String format,
                              String zone)
        get time based on format and time zone
        Parameters:
        time -
        format -
        zone -
        Returns:
      • getTime

        public String getTime​(String timeString,
                              String format,
                              String outputZone,
                              String zone)
        get time based on format and time zone
        Parameters:
        time -
        format -
        zone -
        Returns:
      • getTime

        public String getTime​(String timeString,
                              String format,
                              String zone,
                              String outputZone,
                              Locale locale)
        get time based on format and time zone
        Parameters:
        time -
        format -
        zone -
        Returns:
      • getDayOfWeekIndex

        public int getDayOfWeekIndex​(String day)
        get day of week
        Parameters:
        day -
        Returns:
      • getDayOfWeekIndex

        public int getDayOfWeekIndex​(LocalDateTime time)
        get day of week
        Parameters:
        time -
        Returns:
      • getMonthOfYearIndex

        public int getMonthOfYearIndex​(String month)
        get month of year
        Parameters:
        time -
        Returns:
      • getMonthOfYearIndex

        public int getMonthOfYearIndex​(LocalDateTime time)
        get month of year
        Parameters:
        time -
        Returns:
      • isBetweenDates

        public boolean isBetweenDates​(String source,
                                      String date1,
                                      String date2)
        is source date between date1 and date2
        Parameters:
        source -
        date1 -
        date2 -
        Returns:
      • isBetweenDates

        public boolean isBetweenDates​(List<String> sources,
                                      String date1,
                                      String date2)
        are source dates between date1 and date2
        Parameters:
        sources -
        date1 -
        date2 -
        Returns:
      • isDateAfter

        public boolean isDateAfter​(String source,
                                   String date1)
        if date is after target date1
        Parameters:
        source -
        date1 -
        Returns:
      • isDateAfter

        public boolean isDateAfter​(List<String> sources,
                                   String date1)
        if date list is after target date1
        Parameters:
        source -
        date1 -
        Returns:
      • isDateBefore

        public boolean isDateBefore​(String source,
                                    String date1)
        if date list is before date1
        Parameters:
        source -
        date1 -
        Returns:
      • isDateBefore

        public boolean isDateBefore​(List<String> sources,
                                    String date1)
        if date list is before date1
        Parameters:
        source -
        date1 -
        Returns:
      • isDateEqual

        public boolean isDateEqual​(String source,
                                   String target)
        is source string equal target date string
        Parameters:
        source -
        target -
        Returns:
      • isDateEqual

        public boolean isDateEqual​(List<String> sources,
                                   String target)
        is source string eqia; target date string
        Parameters:
        sources -
        date1 -
        Returns:
      • isDateNotEqual

        public boolean isDateNotEqual​(String source,
                                      String target)
        is source string not equal target date string
        Parameters:
        source -
        target -
        Returns:
      • isDateNotEqual

        public boolean isDateNotEqual​(List<String> sources,
                                      String target)
        is source string not equal target date string
        Parameters:
        sources -
        date1 -
        Returns:
      • getLocalDateTime

        public LocalDateTime getLocalDateTime​(String timeString)
        get local date time from date string
        Parameters:
        timeString -
        Returns:
      • getTime

        public String getTime​(String parameter,
                              String timeString)
        get time based time modification, format or fixed time eg. <@_TIME_ISO_17+30h;setTime:14h23m33s> or <@_TIME_ISO_17+30h;FORMAT:yyyyMMddHHmmssSSS> order of calculation: setTime,setDay,setMonth,time modification (+-hmdwm), format,timezone,locale
        Parameters:
        parameter -
        timeString -
        Returns:
      • setTimeParameterFormat

        public String setTimeParameterFormat​(String parameter)
        setTime, setDay, setMonth parameters at beginning of date modification list
        Parameters:
        parameter -
        Returns:
      • setInitialDate

        public String setInitialDate​(String parameter)
        set time to time overwrites the TestObject.START_TIME_STRING value
        Parameters:
        parameter -
        Returns:
      • setTime

        public String setTime​(String parameter,
                              String timeString)
        sets time based on format: setTime:hh:mm:ss eg: 14:42:33 any combination will work uses utc zone to set time
        Parameters:
        parameter -
        timeString -
        Returns:
      • setDay

        public String setDay​(String dayName,
                             String timeString)
        set day based on format setDay:Day
        Parameters:
        parameter -
        timeString -
        Returns:
      • setMonth

        public String setMonth​(String monthName,
                               String timeString)
        set month based on format setMonth:Month
        Parameters:
        monthName -
        timeString -
        Returns:
      • removeFirstAndLastChars

        public String removeFirstAndLastChars​(String value,
                                              String... toRemove)
        removes surrounding character from string
        Parameters:
        value -
        toRemove -
        Returns:
      • getTimeWithModification

        public String getTimeWithModification​(String parameter,
                                              String timeString)
        time: _TIME_STRING_17-72h or _TIME_STRING_17+72h
        Parameters:
        parameter - : time parameter with modification. eg. _TIME_STRING_17-72h
        timeString -
        Returns: