Class FlowableExpressionTimeUtils

java.lang.Object
com.flowable.platform.expressions.FlowableExpressionTimeUtils

public class FlowableExpressionTimeUtils extends Object
Expression Bean Name: flw.time Provides a number of date and time utilities which can be used in expressions. Please note that all operations use UTC as time zone. Example: #{flwTimeUtils.currentDate()} Example: #{flwTimeUtils.plusDays(flwTimeUtils.now(), 10)}
  • Constructor Details

    • FlowableExpressionTimeUtils

      public FlowableExpressionTimeUtils()
  • Method Details

    • parseInstant

      public Instant parseInstant(String instantIsoString)
      Parse an ISO 8601 String to Instant.
      Parameters:
      instantIsoString - the ISO 8601 String, never null
      Returns:
      the Instant representing the ISO 8601 String
    • parseInstant

      public Instant parseInstant(Object value, String pattern)
      Parse the object in to an Instant Supported inputs are:
      • String
      • Json TextNode
      • null
      Parameters:
      value - the object that should be parsed
      pattern - the pattern that should be used for the parsing
      Returns:
      the Instant representing the object, or null if the object was null
    • parseLocalDate

      public LocalDate parseLocalDate(Object value, String pattern)
      Parse the object in to a LocalDate Supported inputs are:
      • String
      • Json TextNode
      • null
      Parameters:
      value - the object that should be parsed
      pattern - the pattern that should be used for parsing
      Returns:
      the LocalDate representing the object, or null if the object was null
    • parseLocalDateTime

      public LocalDateTime parseLocalDateTime(Object value, String pattern)
      Parse the object in to a LocalDateTime Supported inputs are:
      • String
      • Json TextNode
      • null
      Parameters:
      value - the object that should be parsed
      pattern - the pattern that should be used for parsing
      Returns:
      the LocalDateTime representing the object, or null if the object was null
    • asInstant

      public Instant asInstant(Object value)
      Converts a value to an Instant. Supported inputs are:
      • Date
      • Instant - it will return itself
      • LocalDate - It will use the start of day in the UTC zone
      • LocalDateTime - It will use the UTC zone
      • ISO 8601 String - also supports LocalDate and LocalDateTime values
      • null
      Parameters:
      value - the value to be converted
      Returns:
      An Instant based on the provided value.
    • asInstant

      public Instant asInstant(Object value, String zoneId)
      Converts a value to an Instant in the given zone. Supported inputs are:
      • Date
      • Instant - it will return itself
      • LocalDate - It will use the start of day in the requested zone
      • LocalDateTime - It will use the requested zone
      • ISO 8601 String - also supports LocalDate and LocalDateTime values
      • null
      IMPORTANT: The zoneId is only used when the value is a LocalDate, LocalDateTime or a String representing a LocalDate or LocalDateTime
      Parameters:
      value - the value to be converted
      zoneId - the zone that should be used for converting a LocalDate or LocalDateTime
      Returns:
      An Instant based on the provided value.
    • asInstant

      protected Instant asInstant(Object value, ZoneId zoneId)
    • asLocalDate

      public LocalDate asLocalDate(Object value)
      Converts a value to a LocalDate. Supported inputs are:
      • Date - It will use the LocalDate in the UTC zone
      • Instant - It will use the LocalDate in the UTC zone
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - also supports Instant, LocalDate and LocalDateTime values
      • null
      Parameters:
      value - the value to be converted
      Returns:
      A LocalDate based on the provided value.
    • asLocalDate

      public LocalDate asLocalDate(Object value, String zoneId)
      Converts a value to a LocalDate in the given zone. Supported inputs are:
      • Date - It will use the LocalDate in the provided zone
      • Instant - It will use the LocalDate in the provided zone
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - also supports Instant, LocalDate and LocalDateTime values
      • null
      IMPORTANT: The zoneId is only used when the value is an Instant, Date or a String representing an Instant
      Parameters:
      value - the value to be converted
      zoneId - the zone that should be used for converting a LocalDate or LocalDateTime
      Returns:
      A LocalDate based on the provided value.
    • asLocalDate

      protected LocalDate asLocalDate(Object value, ZoneId zoneId)
    • asLocalDateTime

      public LocalDateTime asLocalDateTime(Object value)
      Converts a value to a LocalDateTime. Supported inputs are:
      • Date - It will use the LocalDateTime in the UTC zone
      • Instant - It will use the LocalDateTime in the UTC zone
      • LocalDate - It will use start of day
      • LocalDateTime
      • ISO 8601 String - also supports Instant, LocalDate and LocalDateTime values
      • null
      Parameters:
      value - the value to be converted
      Returns:
      A LocalDateTime based on the provided value.
    • asLocalDateTime

      public LocalDateTime asLocalDateTime(Object value, String zoneId)
      Converts a value to a LocalDateTime in the given zone. Supported inputs are:
      • Date - It will use the LocalDateTime in provided zone
      • Instant - It will use the LocalDateTime in provided zone
      • LocalDate - It will use start of date
      • LocalDateTime
      • ISO 8601 String - also supports Instant, LocalDate and LocalDateTime values
      • null
      IMPORTANT: The zoneId is only used when the value is an Instant, Date or a String representing an Instant
      Parameters:
      value - the value to be converted
      zoneId - the zone that should be used for converting a LocalDate or LocalDateTime
      Returns:
      A LocalDateTime based on the provided value.
    • asLocalDateTime

      protected LocalDateTime asLocalDateTime(Object value, ZoneId zoneId)
    • asDate

      public Date asDate(Object value)
      Converts a value to a date. This is useful in places where the old Java Date API is still used. Supported inputs are:
      • Instant
      • LocalDate - It will use the start of day in the UTC zone
      • LocalDateTime - It will use the UTC zone
      • ISO 8601 String - also supports LocalDate and LocalDateTime values
      • null
      Parameters:
      value - the value to be converted
      Returns:
      A Date based on the provided value.
    • atTime

      public Object atTime(Object value, int hours, int minutes, int seconds)
      Sets the time of the value to the specified hours, minutes and seconds. The ZoneOffset is UTC. The value can be:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      hours - the hours to be set
      minutes - the minutes to be set
      seconds - the seconds to be set
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • atTimeWithTimeZone

      public Object atTimeWithTimeZone(Object value, int hours, int minutes, int seconds, String timezoneId)
      Sets the time of the value to the specified hours, minutes and seconds in the given timezone. The value can be:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Sets the time of an instant or date to the specified hours, minutes and seconds and returns that time in a specified time zone. Example: Get the current date and time (now) in UTC, set the time to 10:00:00 AM and return the time in the time zone "Europe/Zurich" which will have an offset of either 1 or 2 hours, depending on the time of the year.
      Parameters:
      value - the basis
      hours - the hours to be set
      minutes - the minutes to be set
      seconds - the seconds to be set
      timezoneId - the time zone
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • atTimeZone

      public Object atTimeZone(Object dateOrInstant, String timeZoneId)
      Returns an instant at a specified time zone.
      This is useful in application where more than one time zone is involved and users in different time zones
      receive dates offset to their specific time zones.
      Example: #{flwTimeUtils.atTimeZone(flwTimeUtils.now(), 'Europe/Zurich')} will return the current time in Zurich
      A list of all available time zones can be received with getAvailableTimeZoneIds()
      A more or less up-to-date list can also be found here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ATTENTION: This is for display purposes only, never store a date in a specific time zone!
      Parameters:
      dateOrInstant - base Date or Instant
      timeZoneId - the timeZone ID
      Returns:
      An Date or Instant, offset by the specified timeZoneId
    • getAvailableTimeZoneIds

      public List<String> getAvailableTimeZoneIds()
      Receives a list of all available timeZoneIds maintained as specified by the IANA.
      Use this method if you want to provide a selection of time zones to an end user.
      Returns:
      A list of valid time zones usable with atTimeZone(Object, String)
    • getField

      public int getField(Object value, String chronoFieldString)
      Obtains a "slice of time" by specifying a ChronoField as String.
      The method supports both, the display name and the enum name of ChronoFields.
      Example: #{flwTimeUtils.getField(flwTimeUtils.now(), "DAY_OF_WEEK")} to obtain the current day of the week
      Example: #{flwTimeUtils.getField(flwTimeUtils.now(), "SECOND_OF_MINUTE")} to obtain the seconds in the current minute
      Example: #{flwTimeUtils.getField(flwTimeUtils.now(), "AlignedWeekOfYear")} to obtain the calendar week. This example uses the display name of the Chrono Field.
      A list of all Chrono Fields can be found here:
      https://docs.oracle.com/javase/8/docs/api/java/time/temporal/ChronoField.html. Supports input for:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      value - from which te time should be extracted
      chronoFieldString - the name of a chrono field, see ChronoField
      Returns:
      An int representing the desired ChronoField of the instance in UTC.
    • isWeekend

      public boolean isWeekend(Object value)
      Determines whether the current day is a weekend. It can check the following types:
      • Date
      • Instant - The check is done in the UTC zone
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      value - a Date or Instant
      Returns:
      A Boolean which indicates whether the current day is a weekend
    • fullDateTimeInstant

      public Instant fullDateTimeInstant(int year, int month, int day, int hour, int minute, int second)
      Constructs an Instant based on a given year, month, day, hour, minute and second.
      Parameters:
      year - the year to use
      month - the month to use
      day - the day to use
      hour - the hour to use
      minute - the minute to use
      second - the second to use
      Returns:
      An Instant
    • fullDateTimeDate

      public Date fullDateTimeDate(int year, int month, int day, int hour, int minute, int second)
      Constructs an Date based on a given year, month, day, hour, minute and second.
      Parameters:
      year - the year to use
      month - the month to use
      day - the day to use
      hour - the hour to use
      minute - the minute to use
      second - the second to use
      Returns:
      An Date
    • plusSeconds

      public Object plusSeconds(Object value, long seconds)
      Adds seconds to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      seconds - the number of seconds to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusMinutes

      public Object plusMinutes(Object value, long minutes)
      Adds minutes to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      minutes - the number of minutes to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusHours

      public Object plusHours(Object value, long hours)
      Adds hours to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      hours - the number of hours to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusDays

      public Object plusDays(Object value, long days)
      Adds days to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      days - the number of days to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusWeeks

      public Object plusWeeks(Object value, long weeks)
      Adds weeks to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      weeks - the number of weeks to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusMonths

      public Object plusMonths(Object value, long months)
      Adds months to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      months - the number of months to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusYears

      public Object plusYears(Object value, long years)
      Adds years to the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      years - the number of years to add
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • plusDuration

      public Object plusDuration(Object value, String iso8601Duration)
      Adds an ISO8601-encoded duration to the value.

      Example: #{flwTimeUtils.plusDuration(flwTimeUtils.now(), 'P1Y')} adds a year

      Example: #{flwTimeUtils.plusDuration(flwTimeUtils.now(), 'P14D')} adds 14 days

      Example: #{flwTimeUtils.plusDuration(flwTimeUtils.now(), 'PT30M10S')} adds 30 minutes and ten seconds

      Supports the following input:

      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      IMPORTANT: If the value does not support adding the duration there will be an exception.
      Parameters:
      value - the basis
      iso8601Duration - the duration to be added to the value
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusSeconds

      public Object minusSeconds(Object value, long seconds)
      Subtracts seconds from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      seconds - the number of seconds to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusMinutes

      public Object minusMinutes(Object value, long minutes)
      Subtracts minutes from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      minutes - the number of minutes to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusHours

      public Object minusHours(Object value, long hours)
      Subtracts hours from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDateTime
      • ISO 8601 String - It will return an Instant or LocalDateTime
      Parameters:
      value - the basis
      hours - the number of hours to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusDays

      public Object minusDays(Object value, long days)
      Subtracts days from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      days - the number of days to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusWeeks

      public Object minusWeeks(Object value, long weeks)
      Subtracts weeks from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      weeks - the number of weeks to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusMonths

      public Object minusMonths(Object value, long months)
      Subtracts months from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      months - the number of months to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusYears

      public Object minusYears(Object value, long years)
      Subtracts years from the defined value. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      Parameters:
      value - the basis
      years - the number of years to subtract
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • minusDuration

      public Object minusDuration(Object value, String iso8601Duration)
      Subtracts an ISO8601-encoded duration to the value.

      Example: #{flwTimeUtils.minusDuration(flwTimeUtils.now(), 'P1Y')} subtracts a year

      Example: #{flwTimeUtils.minusDuration(flwTimeUtils.now(), 'P14D')} subtracts 14 days

      Example: #{flwTimeUtils.minusDuration(flwTimeUtils.now(), 'PT30M10S')} subtracts 30 minutes and ten seconds

      Supports the following input:

      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String - It will return an Instant, LocalDate or LocalDateTime
      IMPORTANT: If the value does not support subtracting the duration there will be an exception.
      Parameters:
      value - the basis
      iso8601Duration - the duration to be subtracted from the value
      Returns:
      A new basis type, with the same type as the value (unless it is a string)
    • secondsOfDuration

      public long secondsOfDuration(String iso8601Duration)
      Gets the number of seconds in a ISO duration string, e.g. PT60M returns 3600.
      Parameters:
      iso8601Duration - the ISO 8601 duration string, never null
      Returns:
      Number of seconds in the given duration
    • currentDate

      public Instant currentDate()
      Returns the current date at 00:00 AM UTC.
      Returns:
      An Instant of the current date at 00:00 AM UTC.
    • isBefore

      public boolean isBefore(Object firstValue, Object secondValue)
      Checks if the first value is before the second value. The check is done by converting the second value to the same type as the first one. It allows comparing:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - first value to compare
      secondValue - second value to which to compare to
      Returns:
      true if the first value is before the second one, false otherwise
    • isBeforeOrEqual

      public boolean isBeforeOrEqual(Object firstValue, Object secondValue)
      Checks if the first value is before or equals to the second value. The check is done by converting the second value to the same type as the first one. It allows comparing:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - first value to compare
      secondValue - second value to which to compare to
      Returns:
      true if the first value is before the second one, false otherwise
    • isAfter

      public boolean isAfter(Object firstValue, Object secondValue)
      Checks if the first value is after the second value. The check is done by converting the second value to the same type as the first one. It allows comparing:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - first value to compare
      secondValue - second value to which to compare to
      Returns:
      true if the first value is after the second one, false otherwise
    • isAfterOrEqual

      public boolean isAfterOrEqual(Object firstValue, Object secondValue)
      Checks if the first value is after or equal to the second value. The check is done by converting both values to an Instant and then comparing them. It allows comparing:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - first value to compare
      secondValue - second value to which to compare to
      Returns:
      true if the first value is after the second one, false otherwise
    • areEqual

      public boolean areEqual(Object firstValue, Object secondValue)
      Checks if the first value is equal to the second value. The check is done by converting the second value to the same type as the first one. It allows comparing:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - first value to compare
      secondValue - second value to which to compare to
      Returns:
      true if the first value is equal to the second one, false otherwise
    • isBeforeTime

      public boolean isBeforeTime(Object value, String timeZoneId, int hours, int minutes, int seconds)
      Checks if the given value is before a certain time in a given time zone. The value can be
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String

      The conversion is done by converting the value into an instant in the given time zone.

      Parameters:
      value - to compare the time to
      timeZoneId - the time zone in which to do the comparison
      hours - hour within the same day
      minutes - minutes within the hour
      seconds - seconds within the minute
      Returns:
      true if the value is before the given time, false otherwise
    • isAfterTime

      public boolean isAfterTime(Object value, String timeZoneId, int hours, int minutes, int seconds)
      Checks if the given value is after a certain time in a given time zone. The value can be
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String

      The conversion is done by converting the value into an instant in the given time zone.

      Parameters:
      value - to compare the time to
      timeZoneId - the time zone in which to do the comparison
      hours - hour within the same day
      minutes - minutes within the hour
      seconds - seconds within the minute
      Returns:
      true if the value is after the given time, false otherwise
    • secondsBetweenDates

      @Deprecated public long secondsBetweenDates(Object firstValue, Object secondValue)
      Deprecated.
      Returns the number of seconds between two values. Each value will be converted to an Instant in the UTC timezone before doing the comparison. The values can be
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      Number of seconds between the two values
    • getFieldFromDurationBetweenDates

      public long getFieldFromDurationBetweenDates(Object firstDateOrInstant, Object secondDateOrInstant, String chronoUnitString)
      Gets the duration between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      The following units are supported: Nanos, Micros, Millis, Seconds, Hours, HalfDays, Days, Weeks, Months, Years, Decades, Centuries, Millenia Please note that the number will always be a long, i.e. the number will always be rounded.
      Parameters:
      firstDateOrInstant - the first Date or Instant
      secondDateOrInstant - the second Date or Instant
      chronoUnitString - chrono Unit to be extracted, e.g. 'Seconds' or 'Days', see ChronoUnit for available values
      Returns:
      the duration between the two values in the specific unit
    • secondsBetween

      public long secondsBetween(Object firstValue, Object secondValue)
      Get the number of seconds between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of seconds between the two values
    • minutesBetween

      public long minutesBetween(Object firstValue, Object secondValue)
      Get the number of minutes between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of minutes between the two values
    • hoursBetween

      public long hoursBetween(Object firstValue, Object secondValue)
      Get the number of hours between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of hours between the two values
    • daysBetween

      public long daysBetween(Object firstValue, Object secondValue)
      Get the number of days between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of days between the two values
    • weeksBetween

      public long weeksBetween(Object firstValue, Object secondValue)
      Get the number of weeks between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of weeks between the two values
    • monthsBetween

      public long monthsBetween(Object firstValue, Object secondValue)
      Get the number of months between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of months between the two values
    • yearsBetween

      public long yearsBetween(Object firstValue, Object secondValue)
      Get the number of years between two values. Supports the following input:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      Parameters:
      firstValue - the first value
      secondValue - the second value
      Returns:
      the number of years between the two values
    • getDurationBetween

      protected long getDurationBetween(Object firstValue, Object secondValue, ChronoUnit chronoUnit)
    • getTimeZoneOffset

      public long getTimeZoneOffset(Object value, String timeZoneId)
      Calculates the number of seconds a specific point in time at a specified time zone is set off from UTC. The value can be:
      • Date
      • Instant
      • LocalDate
      • LocalDateTime
      • ISO 8601 String
      This is useful to calculate the time in another time zone. Please note that you should never store the result of such calculations since

      Example: #{flwTimeUtils.getTimZoneOffset(flwTimeUtils.now(), "Pacific/Honolulu)} calculates the number of seconds between Honolulu and UTC time

      Parameters:
      value - the date you want to check the offset at
      timeZoneId - the time zone
      Returns:
      The offset in seconds
    • instantFromTimestamp

      public Instant instantFromTimestamp(long timestamp)
      Returns an instant from the number of seconds that have passed since the first of January 1970 (Unix Timestamp).
      Parameters:
      timestamp -
      Returns:
      Instant at the specified time stamp.
    • dateFromTimestamp

      public Date dateFromTimestamp(long timestamp)
      Returns a date from the number of seconds that have passed since the first of January 1970 (Unix Timestamp).
      Parameters:
      timestamp -
      Returns:
      Date at the specified time stamp.
    • now

      public Instant now()
      Returns the current date and time in UTC.
      Returns:
      Current date and time
    • currentLocalDate

      public LocalDate currentLocalDate()
    • currentLocalDateTime

      public LocalDateTime currentLocalDateTime()