Class NowAndTodayUtil


  • public final class NowAndTodayUtil
    extends Object
    Handles 'NOW' and 'TODAY' for Date / Time type columns
    • Method Detail

      • isNowOrTodayFormat

        public static boolean isNowOrTodayFormat​(String value)
        Checks if date starts with "NOW" or "TODAY".
        Parameters:
        value - value to test
        Returns:
        true if value starts with "NOW" or "TODAY" (case insensitive), false otherwise.
      • doNowOrToday

        public static Date doNowOrToday​(String value,
                                        String colType)
                                 throws DateParseException
        Determines value for "NOW" or "TODAY" prefixed value. "NOW" format can simply be "NOW" (case insensitive), or "NOW" followed by a "+" or "=", then an integer, then a unit. "M" or "MINUTE" or "MINUTES", "H" or "HOUR" or "HOURS", "D" or "DAY" or "DAYS", "Y", "YEAR", or 'YEARS". "TODAY" format can be simply "TODAY" (case insensitive), or "TODAY" followed by a "+" or "-", then an integer, to calculate an offset from today.
        Parameters:
        value - value to convert to a date
        colType - Column type (e.g. "timestamp", "time", "date", or "datetime")
        Returns:
        calculated date, or null if is not a NOW or TODAY prefixed value.
        Throws:
        DateParseException - if colType is not one of "timestamp", "time", "date", or "datetime"