Class TravelDateUtils
java.lang.Object
de.hybris.platform.travelservices.utils.TravelDateUtils
Class which provides Date utility methods
-
Method Summary
Modifier and TypeMethodDescriptionstatic DateMethod to increment the date by the given number of daysstatic InstantAdd hours instant.static DateIncrease the hours in theDateby the specified amountstatic DateMethod to increment the date by the given number of monthsstatic StringconvertDateToGivenTimeOffset(Date inputDate, ZoneId inputZone) Sets a date Object to given ZoneOffset.static StringconvertDateToStringDate(Date date, String pattern) Method takes aDateand return a string representation based on the pattern.static XMLGregorianCalendarconvertInstantToXMLGregorianCalendar(Instant paymentTimeLimit) Convert instant to xml gregorian calendar xml gregorian calendar.static DateconvertStringDateToDate(String date, String pattern) static DateconvertStringDateToDate(String date, String pattern, String zoneId) static StringconvertStringDateToGivenFormat(String inputDateString, String dateFormat) Returns a date String , formatted into given Format.static StringconvertToISODuration(Long duration) Convert the milliseconds to ISO-8601 representationstatic DatecreateDateFromIsoDateFormat(String dateParameter, String pattern) Returns a date object based the String, formatted according to the pattern.static XMLGregorianCalendarDate to xml gregorian calendar.SimpleDateFormatstatic DateReturns a date object based the String, formatted according to the pattern.static DategetDateWithTime(Date date, String time, String pattern) Sets hours, minutes and period in a date and returns the updated datestatic longgetDaysBetweenDates(Date startDate, Date endDate) Gets days between dates.static StringgetTimeForDate(Date date, String pattern) Returns a time based on Date, formatted according to the pattern.static ZonedDateTimegetUtcZonedDateTime(Date date, ZoneId zoneId) Method to get the ZoneDateTime with the UTC time-zone given a Date and its ZoneId.getValidDates(String cronJobExpression, Date fromDate, Date toDate) Returns a list of dates from 'fromDate' to 'toDate'(both dates excluded) based on cronJobExpression.static longgetYearsBetweenDates(Date startDate, Date endDate) Method to find the difference in years between two datesstatic ZonedDateTimegetZonedDateTime(Date date, ZoneId zoneId) Method to get the ZonedDateTime object from a date and its zoneId.static booleanCheck if date1 is after date2 based on the their UTC time.static booleanCheck if date1 is before date2 based on the their UTC time.static booleanisBetweenDates(Date dateToCheck, Date startDate, Date endDate) Returns true if date belongs to the interval (startDate, endDate)static booleanisSameDate(Date date1, Date date2) Check to see if two dates are the samestatic booleanisSameTime(Date departureTime1, Date departureTime2) Returns true if the time component of two date corresponds, false otherwise
-
Method Details
-
convertStringDateToDate
-
convertStringDateToDate
-
convertDateToStringDate
Method takes aDateand return a string representation based on the pattern. -
addHours
Increase the hours in theDateby the specified amount- Parameters:
date- theDateobject to increment by x hourshours- the number of hours to increment by- Returns:
- Date date
-
convertInstantToXMLGregorianCalendar
public static XMLGregorianCalendar convertInstantToXMLGregorianCalendar(Instant paymentTimeLimit) throws DatatypeConfigurationException Convert instant to xml gregorian calendar xml gregorian calendar.- Parameters:
paymentTimeLimit- the payment time limit- Returns:
- the xml gregorian calendar
- Throws:
DatatypeConfigurationException- the datatype configuration exception
-
addHours
Add hours instant.- Parameters:
date- the datehours- the hours- Returns:
- the instant
-
isSameDate
Check to see if two dates are the same- Parameters:
date1- the date to comparedate2- the date to be compared with- Returns:
- true if dates are the same
-
addDays
Method to increment the date by the given number of days- Parameters:
date- the date to incrementamount- the number of days to increment by- Returns:
- incremented date
-
addMonths
Method to increment the date by the given number of months- Parameters:
date- the date to incrementamount- the number of months to increment by- Returns:
- incremented date
-
getYearsBetweenDates
Method to find the difference in years between two dates- Parameters:
startDate- the start dateendDate- the end date- Returns:
- difference in years
-
getUtcZonedDateTime
Method to get the ZoneDateTime with the UTC time-zone given a Date and its ZoneId.- Parameters:
date- the date to be converted in the UTC ZonedDateTimezoneId- the zoneId of the date- Returns:
- the ZonedDateTime with the UTC time-zone.
-
getZonedDateTime
Method to get the ZonedDateTime object from a date and its zoneId.- Parameters:
date- the date to be converted in a ZonedDateTimezoneId- the zoneId of the date- Returns:
- the ZonedDateTime calculated from the date and its zoneId.
-
isBefore
Check if date1 is before date2 based on the their UTC time.- Parameters:
date1- the date to comparezoneId1- the zoneId of date1date2- the date to be compared withzoneId2- the zoneId of date2- Returns:
- true if date1 is before date2 based on their UTC time, false otherwise.
-
isAfter
Check if date1 is after date2 based on the their UTC time.- Parameters:
date1- the date to comparezoneId1- the zoneId of date1date2- the date to be compared withzoneId2- the zoneId of date2- Returns:
- true if date1 is after date2 based on their UTC time, false otherwise.
-
getDaysBetweenDates
Gets days between dates.- Parameters:
startDate- the start dateendDate- the end date- Returns:
- the days between dates
-
getDateWithTime
Sets hours, minutes and period in a date and returns the updated date- Parameters:
date- the datetime- the timepattern- the pattern- Returns:
- date with time
-
getDate
Returns a date object based the String, formatted according to the pattern.- Parameters:
date- the datepattern- the pattern- Returns:
- date date
-
getTimeForDate
Returns a time based on Date, formatted according to the pattern.- Parameters:
date- the date with timepattern- the pattern- Returns:
- time time for date
-
getValidDates
Returns a list of dates from 'fromDate' to 'toDate'(both dates excluded) based on cronJobExpression.- Parameters:
cronJobExpression- the cronJobExpressionfromDate- the date to be used as a starting point reference for calculation of valid datestoDate- the date to be used as a ending point reference for calculation of valid dates- Returns:
- time valid dates
-
isSameTime
Returns true if the time component of two date corresponds, false otherwise- Parameters:
departureTime1- the first date to comparedepartureTime2- the second date to compare- Returns:
- boolean boolean
-
isBetweenDates
Returns true if date belongs to the interval (startDate, endDate)- Parameters:
dateToCheck- date to checkstartDate- lower limitendDate- upper limit- Returns:
- boolean boolean
-
dateToXMLGregorianCalendar
Date to xml gregorian calendar.SimpleDateFormat- Parameters:
date- the date- Returns:
- xml gregorian calendar
-
convertToISODuration
Convert the milliseconds to ISO-8601 representation- Parameters:
duration- the duration- Returns:
- string string
-
createDateFromIsoDateFormat
Returns a date object based the String, formatted according to the pattern.- Parameters:
dateParameter- the dateParameterpattern- the pattern- Returns:
- the date from param
-
convertStringDateToGivenFormat
Returns a date String , formatted into given Format.- Parameters:
inputDateString- the input date stringdateFormat- the date format- Returns:
- the Formatted Date String
-
convertDateToGivenTimeOffset
Sets a date Object to given ZoneOffset.- Parameters:
inputDate- the input dateinputZone- the input zone- Returns:
- the Offset Date String
-