List of usage examples for org.apache.commons.lang.time DateFormatUtils ISO_DATETIME_FORMAT
FastDateFormat ISO_DATETIME_FORMAT
To view the source code for org.apache.commons.lang.time DateFormatUtils ISO_DATETIME_FORMAT.
Click Source Link
From source file:org.sonatype.nexus.plugins.rundeck.VersionOptionProvider.java
/** * @param artifact//from w w w. jav a 2 s . com * @return String representation of the artifact version */ private String buildOptionName(ArtifactInfo artifact) { StringBuilder name = new StringBuilder(); name.append(artifact.version); name.append(" ("); name.append(DateFormatUtils.ISO_DATETIME_FORMAT.format(artifact.lastModified)); name.append(")"); return name.toString(); }
From source file:org.vivoweb.harvester.util.InitLog.java
/** * Set the log level variables//www .j a v a 2 s . c om * @param level the log level */ private static void setLogLevel(String level) { String logLevel = level; if (logLevel == null) { logLevel = ""; } if (logLevel.equalsIgnoreCase("trace") || logLevel.equalsIgnoreCase("all")) { System.setProperty("console-trace", "ACCEPT"); System.setProperty("console-debug", "ACCEPT"); System.setProperty("console-info", "ACCEPT"); System.setProperty("console-warnerror", "WARN"); } else if (logLevel.equalsIgnoreCase("debug")) { System.setProperty("console-trace", "DENY"); System.setProperty("console-debug", "ACCEPT"); System.setProperty("console-info", "ACCEPT"); System.setProperty("console-warnerror", "WARN"); } else if (logLevel.equalsIgnoreCase("info")) { System.setProperty("console-trace", "DENY"); System.setProperty("console-debug", "DENY"); System.setProperty("console-info", "ACCEPT"); System.setProperty("console-warnerror", "WARN"); } else if (logLevel.equalsIgnoreCase("warn")) { System.setProperty("console-trace", "DENY"); System.setProperty("console-debug", "DENY"); System.setProperty("console-info", "DENY"); System.setProperty("console-warnerror", "WARN"); } else if (logLevel.equalsIgnoreCase("error")) { System.setProperty("console-trace", "DENY"); System.setProperty("console-debug", "DENY"); System.setProperty("console-info", "DENY"); System.setProperty("console-warnerror", "ERROR"); } else if (logLevel.equalsIgnoreCase("off")) { System.setProperty("console-trace", "DENY"); System.setProperty("console-debug", "DENY"); System.setProperty("console-info", "DENY"); System.setProperty("console-warnerror", "OFF"); } else { System.clearProperty("console-trace"); System.clearProperty("console-debug"); System.clearProperty("console-info"); System.clearProperty("console-warnerror"); } LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); String task = getFirstValidString(System.getenv("HARVESTER_TASK_DATE"), System.getProperty("harvester-task"), "harvester." + DateFormatUtils.ISO_DATETIME_FORMAT.format(System.currentTimeMillis())); context.putProperty("harvester-task", task); String process = getFirstValidString(System.getenv("PROCESS_TASK"), System.getProperty("process-task"), "all"); context.putProperty("process-task", process); JoranConfigurator jc = new JoranConfigurator(); jc.setContext(context); try { InputStream is; is = FileAide.getFirstFileNameChildInputStream(".", "logback-test.xml"); if (is == null) { is = FileAide.getFirstFileNameChildInputStream(".", "logback.xml"); } if (is == null) { is = Thread.currentThread().getContextClassLoader().getResourceAsStream("logback-test.xml"); } if (is == null) { is = Thread.currentThread().getContextClassLoader().getResourceAsStream("logback.xml"); } if (is != null) { context.reset(); context.stop(); jc.doConfigure(is); context.start(); } } catch (IOException e) { throw new IllegalArgumentException(e); } catch (JoranException e) { throw new IllegalArgumentException(e); } }
From source file:oscar.oscarDemographic.pageUtil.ImportDemographicDataAction4.java
/** * Terrible method.//from w ww.j a v a 2 s . co m * Not my fault, you should have used a Date object to begin with not a String. Now I have to undo your mess. */ private static Date toDateFromString(String s) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return (sdf.parse(s)); } catch (Exception e) { // okay we couldn't parse it, we'll try another format } try { SimpleDateFormat sdf = new SimpleDateFormat(DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()); return (sdf.parse(s)); } catch (Exception e) { // okay we couldn't parse it, we'll try another format } try { SimpleDateFormat sdf = new SimpleDateFormat(DateFormatUtils.ISO_DATE_FORMAT.getPattern()); return (sdf.parse(s)); } catch (Exception e) { // okay we couldn't parse it, we'll try another format } // no more formats to try, we lose :( logger.warn("UnParsable date string : " + s); return (null); }
From source file:oscar.util.DateUtils.java
public static String getISODateTimeFormatNoT(Calendar cal) { return (DateFormatUtils.ISO_DATETIME_FORMAT.format(cal).replace('T', ' ')); }