Class DateUtil

java.lang.Object
org.owasp.dependencycheck.utils.DateUtil

@ThreadSafe public final class DateUtil extends Object
Author:
Jeremy Long
  • Method Details

    • parseXmlDate

      public static Calendar parseXmlDate(String xsDate) throws ParseException
      Parses an XML xs:date into a calendar object.
      Parameters:
      xsDate - an xs:date string
      Returns:
      a calendar object
      Throws:
      ParseException - thrown if the date cannot be converted to a calendar
    • withinDateRange

      public static boolean withinDateRange(long date, long compareTo, int dayRange)
      Determines if the epoch date is within the range specified of the compareTo epoch time. This takes the (compareTo-date)/1000/60/60/24 to get the number of days. If the calculated days is less then the range the date is considered valid.
      Parameters:
      date - the date to be checked.
      compareTo - the date to compare to.
      dayRange - the range in days to be considered valid.
      Returns:
      whether or not the date is within the range.
    • withinDateRange

      public static boolean withinDateRange(ZonedDateTime date, ZonedDateTime compareTo, int dayRange)
      Determines if the date is within the given day range.
      Parameters:
      date - the date
      compareTo - the date to compare against
      dayRange - the number of days allowed
      Returns:
      if the date is within the dayRange of compareTo
    • getEpochValueInSeconds

      public static long getEpochValueInSeconds(String epoch)
      Returns the string value converted to an epoch seconds. Note, in some cases the value provided may be in milliseconds.
      Parameters:
      epoch - the property value
      Returns:
      the value in seconds