Class ExpressionInstant


  • public final class ExpressionInstant
    extends Object
    A wrapper of the Instant plus/minus functions for use in expressions. It ensures that multiple calls to the wrapped functions are always based on the same instant in time. For example, if added to the bindings as now:
          
          "iat": "${now.epochSeconds}",
          "exp": "${now.plusMinutes(30).epochSeconds}",
          "expires", "${now.plusSeconds(20).rfc1123}"
          
      
    • Constructor Detail

      • ExpressionInstant

        public ExpressionInstant​(Instant instant)
        Create a new ExpressionInstant based on the passed Instant.
        Parameters:
        instant - the Instant to use.
    • Method Detail

      • getEpochMillis

        public long getEpochMillis()
        Return the milliseconds since the epoch of 1970-01-01T00:00:00Z.
        Returns:
        the milliseconds since the epoch of 1970-01-01T00:00:00Z
      • getEpochSeconds

        public long getEpochSeconds()
        Return the seconds since the epoch of 1970-01-01T00:00:00Z.
        Returns:
        the seconds since the epoch of 1970-01-01T00:00:00Z
      • getRfc1123

        public String getRfc1123()
        Returns the current instant as a String in the Date format of RFC1123, which is the format used in a Expires value in cookies.
        Returns:
        the current instant as a String in the Date format of RFC1123
        See Also:
        RFC6265 section 4.1.1.
      • plusMillis

        public ExpressionInstant plusMillis​(long millisecondsToAdd)
        Return a new ExpressionInstant with the millisecondsToAdd added to the current value of the Instant.
        Parameters:
        millisecondsToAdd - the milliseconds to add.
        Returns:
        a new ExpressionInstant with the millisecondsToAdd added to the current value of the Instant.
      • minusMillis

        public ExpressionInstant minusMillis​(long millisecondsToSubtract)
        Return a new ExpressionInstant with the millisecondsToSubtract subtracted from the current value of the Instant.
        Parameters:
        millisecondsToSubtract - the milliseconds to subtract.
        Returns:
        a new ExpressionInstant with the millisecondsToSubtract subtracted from the current value of the Instant.
      • plusSeconds

        public ExpressionInstant plusSeconds​(long secondsToAdd)
        Return a new ExpressionInstant with the secondsToAdd added to the current value of the Instant.
        Parameters:
        secondsToAdd - the seconds to add.
        Returns:
        a new ExpressionInstant with the secondsToAdd added to the current value of the Instant.
      • minusSeconds

        public ExpressionInstant minusSeconds​(long secondsToSubtract)
        Return a new ExpressionInstant with the secondsToSubtract subtracted from the current value of the Instant.
        Parameters:
        secondsToSubtract - the seconds to subtract.
        Returns:
        a new ExpressionInstant with the secondsToSubtract subtracted from the current value of the Instant.
      • plusMinutes

        public ExpressionInstant plusMinutes​(long minutesToAdd)
        Return a new ExpressionInstant with the minutesToAdd added to the current value of the Instant.
        Parameters:
        minutesToAdd - the minutes to add.
        Returns:
        a new ExpressionInstant with the minutesToAdd added to the current value of the Instant.
      • minusMinutes

        public ExpressionInstant minusMinutes​(long minutesToSubtract)
        Return a new ExpressionInstant with the minutesToSubtract subtracted from the current value of the Instant.
        Parameters:
        minutesToSubtract - the minutes to subtract.
        Returns:
        a new ExpressionInstant with the minutesToSubtract subtracted from the current value of the Instant.
      • plusHours

        public ExpressionInstant plusHours​(long hoursToAdd)
        Return a new ExpressionInstant with the hoursToAdd added to the current value of the Instant.
        Parameters:
        hoursToAdd - the hours to add.
        Returns:
        a new ExpressionInstant with the hoursToAdd added to the current value of the Instant.
      • minusHours

        public ExpressionInstant minusHours​(long hoursToSubtract)
        Return a new ExpressionInstant with the hoursToSubtract subtracted from the current value of the Instant.
        Parameters:
        hoursToSubtract - the hours to subtract.
        Returns:
        a new ExpressionInstant with the hoursToSubtract subtracted from the current value of the Instant.
      • plusDays

        public ExpressionInstant plusDays​(long daysToAdd)
        Return a new ExpressionInstant with the daysToAdd added to the current value of the Instant.
        Parameters:
        daysToAdd - the days to add.
        Returns:
        a new ExpressionInstant with the daysToAdd added to the current value of the Instant.
      • minusDays

        public ExpressionInstant minusDays​(long daysToSubtract)
        Return a new ExpressionInstant with the daysToSubtract subtracted from the current value of the Instant.
        Parameters:
        daysToSubtract - the days to subtract.
        Returns:
        a new ExpressionInstant with the daysToSubtract subtracted from the current value of the Instant.