Class TimestampPattern


public class TimestampPattern extends AnchorBean<TimestampPattern>
Extracts a timestamp from a file-name if it exists.

A regular-expression specifies whether the file-name matches, and respective groups for year, month, day, hour, minutes, seconds.

Author:
Owen Feehan
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    TimestampPattern(String regularExpression)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The index of the group in regularExpression that encodes the day, starting from 0 for the first group.
    int
    The index of the group in regularExpression that encodes the hours, starting from 0 for the first group.
    int
    The index of the group in regularExpression that encodes the minutes, starting from 0 for the first group.
    int
    The index of the group in regularExpression that encodes the month, starting from 0 for the first group.
    int
    The index of the group in regularExpression that encodes the seconds, starting from 0 for the first group.
    int
    The index of the group in regularExpression that encodes the year, starting from 0 for the first group.
    The regular-expression that checks a match and specifies groups for the encoded date-time.
    match(String fileName, ZoneOffset offset)
    Matches certain times.
    void
    setIndexDay(int indexDay)
    The index of the group in regularExpression that encodes the day, starting from 0 for the first group.
    void
    setIndexHours(int indexHours)
    The index of the group in regularExpression that encodes the hours, starting from 0 for the first group.
    void
    setIndexMinutes(int indexMinutes)
    The index of the group in regularExpression that encodes the minutes, starting from 0 for the first group.
    void
    setIndexMonth(int indexMonth)
    The index of the group in regularExpression that encodes the month, starting from 0 for the first group.
    void
    setIndexSeconds(int indexSeconds)
    The index of the group in regularExpression that encodes the seconds, starting from 0 for the first group.
    void
    setIndexYear(int indexYear)
    The index of the group in regularExpression that encodes the year, starting from 0 for the first group.
    void
    setRegularExpression(String regularExpression)
    The regular-expression that checks a match and specifies groups for the encoded date-time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TimestampPattern

      public TimestampPattern(String regularExpression)
    • TimestampPattern

      public TimestampPattern()
  • Method Details

    • match

      public Optional<Long> match(String fileName, ZoneOffset offset)
      Matches certain times.
      Parameters:
      fileName - the fileName to try and match against the pattern.
      offset - the offset to assume the time-stamp belongs in.
      Returns:
      if the string matches, the number of seconds since the epoch.
    • getRegularExpression

      public String getRegularExpression()
      The regular-expression that checks a match and specifies groups for the encoded date-time.
    • setRegularExpression

      public void setRegularExpression(String regularExpression)
      The regular-expression that checks a match and specifies groups for the encoded date-time.
    • getIndexYear

      public int getIndexYear()
      The index of the group in regularExpression that encodes the year, starting from 0 for the first group.
    • setIndexYear

      public void setIndexYear(int indexYear)
      The index of the group in regularExpression that encodes the year, starting from 0 for the first group.
    • getIndexMonth

      public int getIndexMonth()
      The index of the group in regularExpression that encodes the month, starting from 0 for the first group.
    • setIndexMonth

      public void setIndexMonth(int indexMonth)
      The index of the group in regularExpression that encodes the month, starting from 0 for the first group.
    • getIndexDay

      public int getIndexDay()
      The index of the group in regularExpression that encodes the day, starting from 0 for the first group.
    • setIndexDay

      public void setIndexDay(int indexDay)
      The index of the group in regularExpression that encodes the day, starting from 0 for the first group.
    • getIndexHours

      public int getIndexHours()
      The index of the group in regularExpression that encodes the hours, starting from 0 for the first group.
    • setIndexHours

      public void setIndexHours(int indexHours)
      The index of the group in regularExpression that encodes the hours, starting from 0 for the first group.
    • getIndexMinutes

      public int getIndexMinutes()
      The index of the group in regularExpression that encodes the minutes, starting from 0 for the first group.
    • setIndexMinutes

      public void setIndexMinutes(int indexMinutes)
      The index of the group in regularExpression that encodes the minutes, starting from 0 for the first group.
    • getIndexSeconds

      public int getIndexSeconds()
      The index of the group in regularExpression that encodes the seconds, starting from 0 for the first group.
    • setIndexSeconds

      public void setIndexSeconds(int indexSeconds)
      The index of the group in regularExpression that encodes the seconds, starting from 0 for the first group.