public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.ISO8601_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = // CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); // default to the ISO8601 format cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } List<String> optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if(optionList != null && optionList.size()> 1) { String secondOption = optionList.get(1); if(AUXILIARY_TOKEN.equalsIgnoreCase(secondOption)) { primary = false; } } cdf = new CachingDateFormatter(datePattern); }
public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.ISO8601_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = // CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); // default to the ISO8601 format cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } List optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
Scope scope = ActionUtil.stringToScope(scopeStr); CachingDateFormatter sdf = new CachingDateFormatter(datePatternStr); String val = sdf.format(timeReference);
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if(optionList != null && optionList.size()> 1) { String secondOption = optionList.get(1); if(AUXILIARY_TOKEN.equalsIgnoreCase(secondOption)) { primary = false; } } cdf = new CachingDateFormatter(datePattern); }
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if(optionList != null && optionList.size()> 1) { String secondOption = optionList.get(1); if(AUXILIARY_TOKEN.equalsIgnoreCase(secondOption)) { primary = false; } } cdf = new CachingDateFormatter(datePattern); }
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if (optionList != null) { for (int optionIndex = 1; optionIndex < optionList.size(); optionIndex++) { String option = optionList.get(optionIndex); if (AUXILIARY_TOKEN.equalsIgnoreCase(option)) { primary = false; } else { timeZone = TimeZone.getTimeZone(option); } } } cdf = new CachingDateFormatter(datePattern); if (timeZone != null) { cdf.setTimeZone(timeZone); } }
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if (optionList != null) { for (int optionIndex = 1; optionIndex < optionList.size(); optionIndex++) { String option = optionList.get(optionIndex); if (AUXILIARY_TOKEN.equalsIgnoreCase(option)) { primary = false; } else { timeZone = TimeZone.getTimeZone(option); } } } cdf = new CachingDateFormatter(datePattern); if (timeZone != null) { cdf.setTimeZone(timeZone); } }
public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.ISO8601_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = // CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); // default to the ISO8601 format cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } List optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if (optionList != null) { for (int optionIndex = 1; optionIndex < optionList.size(); optionIndex++) { String option = optionList.get(optionIndex); if (AUXILIARY_TOKEN.equalsIgnoreCase(option)) { primary = false; } else { timeZone = TimeZone.getTimeZone(option); } } } cdf = new CachingDateFormatter(datePattern); if (timeZone != null) { cdf.setTimeZone(timeZone); } }
public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.ISO8601_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = // CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); // default to the ISO8601 format cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } List<String> optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.ISO8601_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = // CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); // default to the ISO8601 format cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } List<String> optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.ISO8601_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = // CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); // default to the ISO8601 format cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } List optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
@Override public void start() { String datePattern = getFirstOption(); if (datePattern == null) { datePattern = CoreConstants.CLF_DATE_PATTERN; } if (datePattern.equals(CoreConstants.ISO8601_STR)) { datePattern = CoreConstants.ISO8601_PATTERN; } try { cachingDateFormatter = new CachingDateFormatter(datePattern); // maximumCacheValidity = CachedDateFormat.getMaximumCacheValidity(pattern); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); addWarn("Defaulting to " + CoreConstants.CLF_DATE_PATTERN); cachingDateFormatter = new CachingDateFormatter(CoreConstants.CLF_DATE_PATTERN); } List optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { TimeZone tz = TimeZone.getTimeZone((String) optionList.get(1)); cachingDateFormatter.setTimeZone(tz); } }
cachingDateFormatter = new CachingDateFormatter(datePattern, locale); } catch (IllegalArgumentException e) { addWarn("Could not instantiate SimpleDateFormat with pattern " + datePattern, e); cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN, locale);
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if (optionList != null) { for (int optionIndex = 1; optionIndex < optionList.size(); optionIndex++) { String option = optionList.get(optionIndex); if (AUXILIARY_TOKEN.equalsIgnoreCase(option)) { primary = false; } else { timeZone = TimeZone.getTimeZone(option); } } } cdf = new CachingDateFormatter(datePattern); if (timeZone != null) { cdf.setTimeZone(timeZone); } }
public void start() { this.datePattern = getFirstOption(); if (this.datePattern == null) { this.datePattern = DEFAULT_DATE_PATTERN; } final List<String> optionList = getOptionList(); if (optionList != null) { for (int optionIndex = 1; optionIndex < optionList.size(); optionIndex++) { String option = optionList.get(optionIndex); if (AUXILIARY_TOKEN.equalsIgnoreCase(option)) { primary = false; } else { timeZone = TimeZone.getTimeZone(option); } } } cdf = new CachingDateFormatter(datePattern); if (timeZone != null) { cdf.setTimeZone(timeZone); } }
@Test public void timestamp() throws JoranException, IOException, InterruptedException { String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "timestamp-context.xml"; configure(configFileAsStr); String r = loggerContext.getProperty("testTimestamp"); assertNotNull(r); CachingDateFormatter sdf = new CachingDateFormatter("yyyy-MM"); String expected = sdf.format(System.currentTimeMillis()); assertEquals("expected \"" + expected + "\" but got " + r, expected, r); }
@Test public void timeZoneIsTakenIntoAccount() throws ParseException { CachingDateFormatter cdf = new CachingDateFormatter(DATE_PATTERN); TimeZone perthTZ = TimeZone.getTimeZone("Australia/Perth"); cdf.setTimeZone(perthTZ); Date march26_2015_0949_UTC = sdf.parse("2015-03-26T09:49"); System.out.print(march26_2015_0949_UTC); String result = cdf.format(march26_2015_0949_UTC.getTime()); // AWST (Perth) is 8 hours ahead of UTC assertEquals("2015-03-26T17:49", result); } }
@Test public void basic() throws Exception { loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "unique.xml"); CachingDateFormatter sdf = new CachingDateFormatter("yyyyMMdd'T'HHmm"); String timestamp = sdf.format(System.currentTimeMillis()); sc.assertIsErrorFree(); Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME); root.info("hello"); File file = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "UNIK_" + timestamp + diffAsStr + "log.txt"); assertTrue(file.exists()); } }