Package core.helpers
Class DateHelper
- java.lang.Object
-
- core.helpers.DateHelper
-
public class DateHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_DATE_CURRENT_ZONEstatic StringCONFIG_DATE_FORMATstatic StringCONFIG_DATE_FORMAT_DEFAULTstatic StringCONFIG_DATE_LOCALstatic StringCONFIG_DATE_OUTPUT_ZONEstatic StringCONFIG_DATE_ZONE_INPUT_DEFAULTstatic StringCONFIG_DATE_ZONE_OUTPUT_DEFAULT
-
Constructor Summary
Constructors Constructor Description DateHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCurrentTime(String format)get current time based on formatStringgetCurrentTime(String format, String currentZone)get current time based on format and time zone output zone will be UTCStringgetCurrentTime(String format, String currentZone, String outputZone, Locale locale)get current time based on localeStringgetCurrentTime(Locale locale)get current time based on localeStringgetCurrentTimeEpochMS()StringgetCurrentTimeEpochSeconds()intgetDayOfWeekIndex(String day)get day of weekintgetDayOfWeekIndex(LocalDateTime time)get day of weekLocalDateTimegetLocalDateTime(String timeString)get local date time from date stringintgetMonthOfYearIndex(String month)get month of yearintgetMonthOfYearIndex(LocalDateTime time)get month of yearStringgetTime(String parameter, String timeString)get time based time modification, format or fixed time eg.StringgetTime(String timeString, String format, String zone)get time based on format and time zoneStringgetTime(String timeString, String format, String outputZone, String zone)get time based on format and time zoneStringgetTime(String timeString, String format, String zone, String outputZone, Locale locale)get time based on format and time zoneStringgetTime(Instant time)get time string output time zone will be UTC by defaultStringgetTime(Instant time, String format)get time based on format output time zone will be UTC by defaultStringgetTime(Instant time, String format, String zone)get time based on format output time zone will be UTC by defaultStringgetTime(Instant time, String format, String currentZone, String outputZone, Locale locale)get time based on formatStringgetTime(Instant time, String format, String zone, Locale locale)get time based on format output time zone will be UTC by defaultStringgetTime(Instant time, String format, Locale locale)get time based on format output time zone will be UTC by defaultStringgetTime(Instant time, Locale locale)get time based on locale output time zone will be UTC by defaultStringgetTimeEpochMS(ZonedDateTime time)StringgetTimeInstance()StringgetTimeISOInstant()StringgetTimestampMiliseconds()StringgetTimestampSeconds()StringgetTimeString(String timeString, String format, String zone, String outputZone, String localeStr)StringgetTimeWithModification(String parameter, String timeString)time: _TIME_STRING_17-72h or _TIME_STRING_17+72hbooleanisBetweenDates(String source, String date1, String date2)is source date between date1 and date2booleanisBetweenDates(List<String> sources, String date1, String date2)are source dates between date1 and date2booleanisDateAfter(String source, String date1)if date is after target date1booleanisDateAfter(List<String> sources, String date1)if date list is after target date1booleanisDateBefore(String source, String date1)if date list is before date1booleanisDateBefore(List<String> sources, String date1)if date list is before date1booleanisDateEqual(String source, String target)is source string equal target date stringbooleanisDateEqual(List<String> sources, String target)is source string eqia; target date stringbooleanisDateNotEqual(String source, String target)is source string not equal target date stringbooleanisDateNotEqual(List<String> sources, String target)is source string not equal target date stringStringremoveFirstAndLastChars(String value, String... toRemove)removes surrounding character from stringStringsetDay(String dayName, String timeString)set day based on format setDay:DayStringsetInitialDate(String parameter)set time to time overwrites the TestObject.START_TIME_STRING valueStringsetMonth(String monthName, String timeString)set month based on format setMonth:MonthStringsetTime(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 timeStringsetTimeParameterFormat(String parameter)setTime, setDay, setMonth parameters at beginning of date modification list
-
-
-
Field Detail
-
CONFIG_DATE_FORMAT
public static final String CONFIG_DATE_FORMAT
- See Also:
- Constant Field Values
-
CONFIG_DATE_CURRENT_ZONE
public static final String CONFIG_DATE_CURRENT_ZONE
- See Also:
- Constant Field Values
-
CONFIG_DATE_OUTPUT_ZONE
public static final String CONFIG_DATE_OUTPUT_ZONE
- See Also:
- Constant Field Values
-
CONFIG_DATE_LOCAL
public static final String CONFIG_DATE_LOCAL
- See Also:
- Constant Field Values
-
CONFIG_DATE_FORMAT_DEFAULT
public static final String CONFIG_DATE_FORMAT_DEFAULT
- See Also:
- Constant Field Values
-
CONFIG_DATE_ZONE_INPUT_DEFAULT
public static final String CONFIG_DATE_ZONE_INPUT_DEFAULT
- See Also:
- Constant Field Values
-
CONFIG_DATE_ZONE_OUTPUT_DEFAULT
public static final String CONFIG_DATE_ZONE_OUTPUT_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTimestampMiliseconds
public String getTimestampMiliseconds()
-
getCurrentTimeEpochSeconds
public String getCurrentTimeEpochSeconds()
-
getCurrentTimeEpochMS
public String getCurrentTimeEpochMS()
-
getTimeEpochMS
public String getTimeEpochMS(ZonedDateTime time)
-
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:
-
getTimeString
public String getTimeString(String timeString, String format, String zone, String outputZone, String localeStr)
-
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:
-
-