class KMLSpatialTemporalUtils {

    static Date getMaxAgeHeaderTime(String cacheControlHeader, LongSupplier currentTimeSupplier)
    {
        Date maxAge = null;
        if (!StringUtils.isBlank(cacheControlHeader))
        {
            String[] pairs = cacheControlHeader.split(",");
            for (String pair : pairs)
            {
                String[] toks = pair.split("=");
                String key = toks[0].trim();
                String value = toks.length >= 2 ? toks[1].trim() : null;
                if ("max-age".equals(key))
                {
                    int maxAgeSeconds;
                    try
                    {
                        maxAgeSeconds = Integer.parseInt(value);
                    }
                    catch (NumberFormatException e)
                    {
                        maxAgeSeconds = 0;
                    }
                    if (maxAgeSeconds > 0)
                    {
                        maxAge = new Date(currentTimeSupplier.get() + (long)maxAgeSeconds * 1000);
                    }
                }
            }
        }
        return maxAge;
    }

    private  KMLSpatialTemporalUtils();

}