MCPcopy Create free account
hub / github.com/apache/tomcat / setDateVariables

Method setDateVariables

java/org/apache/catalina/ssi/SSIMediator.java:523–544  ·  view source on GitHub ↗

Updates the built-in date variables (DATE_GMT, DATE_LOCAL, LAST_MODIFIED). @param fromConstructor true if called from the constructor

(boolean fromConstructor)

Source from the content-addressed store, hash-verified

521 * @param fromConstructor true if called from the constructor
522 */
523 protected void setDateVariables(boolean fromConstructor) {
524 boolean alreadySet = ssiExternalResolver.getVariableValue(className + ".alreadyset") != null;
525 // skip this if we are being called from the constructor, and this has already been set
526 if (!(fromConstructor && alreadySet)) {
527 ssiExternalResolver.setVariableValue(className + ".alreadyset", "true");
528 Date date = new Date();
529 TimeZone timeZone = TimeZone.getTimeZone("GMT");
530 String retVal = formatDate(date, timeZone);
531 /*
532 * If we are setting on of the date variables, we want to remove them from the user defined list of
533 * variables, because this is what Apache does.
534 */
535 setVariableValue("DATE_GMT", null);
536 ssiExternalResolver.setVariableValue(className + ".DATE_GMT", retVal);
537 retVal = formatDate(date, null);
538 setVariableValue("DATE_LOCAL", null);
539 ssiExternalResolver.setVariableValue(className + ".DATE_LOCAL", retVal);
540 retVal = formatDate(new Date(lastModifiedDate), null);
541 setVariableValue("LAST_MODIFIED", null);
542 ssiExternalResolver.setVariableValue(className + ".LAST_MODIFIED", retVal);
543 }
544 }
545
546
547 /**

Callers 1

setConfigTimeFmtMethod · 0.95

Calls 5

formatDateMethod · 0.95
setVariableValueMethod · 0.95
getTimeZoneMethod · 0.80
getVariableValueMethod · 0.65
setVariableValueMethod · 0.65

Tested by

no test coverage detected