Package io.didomi.sdk.resources
Object DateHelper
-
- All Implemented Interfaces:
public class DateHelper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceDateHelper.TimeUnit
-
Field Summary
Fields Modifier and Type Field Description public final static IntegerONE_HOUR_IN_SECONDSpublic final static IntegerONE_DAY_IN_SECONDSpublic final static StringUNIT_YEARpublic final static StringUNIT_MONTHpublic final static StringUNIT_DAYpublic final static StringUNIT_HOURpublic final static StringUNIT_MINUTEpublic final static StringUNIT_SECONDprivate Calendarcalendarpublic final static DateHelperINSTANCE
-
Method Summary
Modifier and Type Method Description final DategetCurrentDate()Method used to get the current date object. final LonggetCurrentTimestamp()Get the current timestamp final StringtoISOString(Date date)Convert a date to an ISO string in UTC final SimpleDateFormatgetDateFormatForISOString()Create a DateFormat ready to format Date objects to ISO strings final BooleanisDateInThePast(Date date)Check whether a date is in the past final DatefromISOString(String date)Get a date from an ISO string with fixed timezone (Z) final StringgetGMTTimestamp(Long timeInMs)Convert a timestamp that can be used in request headers final IntegergetNumberOfDaysBetweenTodayAndDate(Date date)Get the number of days between the specified date and today final IntegergetNumberOfSecondsBetweenNowAndDate(Date date)Get the number of seconds between the specified date and now final StringgetDurationLabel(LanguagesHelper languagesHelper, Long unitCount, String unitKey, Boolean formatBigNumber)Displays duration of time units in human readable format. final StringgetDurationLabelWithSecondsIfNeeded(LanguagesHelper languagesHelper, Long durationInSeconds)Convert duration in seconds into a displayable, human readable approximation of the duration, together with the exact value in seconds if duration is more than 1 minute final CalendargetCalendar()final UnitsetCalendar(Calendar calendar)-
-
Method Detail
-
getCurrentDate
final Date getCurrentDate()
Method used to get the current date object.
-
getCurrentTimestamp
final Long getCurrentTimestamp()
Get the current timestamp
-
toISOString
final String toISOString(Date date)
Convert a date to an ISO string in UTC
- Parameters:
date- to format as Date - nullable
-
getDateFormatForISOString
final SimpleDateFormat getDateFormatForISOString()
Create a DateFormat ready to format Date objects to ISO strings
-
isDateInThePast
final Boolean isDateInThePast(Date date)
Check whether a date is in the past
- Parameters:
date- to compare as Date - nullable
-
fromISOString
final Date fromISOString(String date)
Get a date from an ISO string with fixed timezone (Z)
- Parameters:
date- to parse as String - nullable
-
getGMTTimestamp
final String getGMTTimestamp(Long timeInMs)
Convert a timestamp that can be used in request headers
- Parameters:
timeInMs- the timestamp to format
-
getNumberOfDaysBetweenTodayAndDate
final Integer getNumberOfDaysBetweenTodayAndDate(Date date)
Get the number of days between the specified date and today
- Parameters:
date- to compare as Date
-
getNumberOfSecondsBetweenNowAndDate
final Integer getNumberOfSecondsBetweenNowAndDate(Date date)
Get the number of seconds between the specified date and now
- Parameters:
date- to compare as Date
-
getDurationLabel
final String getDurationLabel(LanguagesHelper languagesHelper, Long unitCount, String unitKey, Boolean formatBigNumber)
Displays duration of time units in human readable format. Unit keys are "year", "month", "day", "hour", "minute", "second".
- Parameters:
languagesHelper- languagesHelper used to get locale-dependant resourcesunitCount- count of to displayunitKey- key for this unitformatBigNumber- whether big number should be formatted according to user language
-
getDurationLabelWithSecondsIfNeeded
final String getDurationLabelWithSecondsIfNeeded(LanguagesHelper languagesHelper, Long durationInSeconds)
Convert duration in seconds into a displayable, human readable approximation of the duration, together with the exact value in seconds if duration is more than 1 minute
- Parameters:
languagesHelper- languagesHelper used to get locale-dependant resourcesdurationInSeconds- the duration in seconds
-
getCalendar
final Calendar getCalendar()
-
setCalendar
final Unit setCalendar(Calendar calendar)
-
-
-
-