Displays the date and / or time when the page was last modified.

Parameters#

  • format=format string : How the date and time should be formatted. If you omit this, a default format will be used.

The format parameter is implemented exactly the same as in the Current Time Plugin, so check out that page for more details on how to use format.

Installation#

There is a couple ways to install the plugin:

  • Get the source file, put it in the source directory with the rest of the plugins (src/com/ecyrd/jspwiki/plugin) and recompile your Wiki. OR:
  • Get the attached JAR file, and put it in the library folder on the server where the wiki is installed. (WEB-INF/lib) After the JAR is in the libraries folder, you might need to reload the JSPWiki webapp through the Tomcat manager (or restart Tomcat if you want to brute-force it :)), and it will auto-magically work.

Usage#

[{INSERT DateModifiedPlugin}]

--Vovan


package com.ecyrd.jspwiki.plugin;

import com.ecyrd.jspwiki.*;
import java.text.SimpleDateFormat;
import java.util.*;

public class DateModifiedPlugin implements WikiPlugin {

  public static final String DEFAULT_FORMAT = "HH:mm:ss dd-MMM-yyyy zzzz";

  public String execute(WikiContext context, Map params)
	throws PluginException {

	String formatString = (String) params.get("format");

	if(formatString == null) {
	  formatString = DEFAULT_FORMAT;
	}

	try {
	  SimpleDateFormat fmt = new SimpleDateFormat(formatString);

	  Date d = context.getPage().getLastModified();

	  if (d == null) {
		return "Never";
	  } else {
		return fmt.format(d);
	  }
	}
	catch(IllegalArgumentException e) {
	  throw new PluginException("You specified bad format: " + e.getMessage());
	}
  }
}

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
jar
DMPlugin.jar 1.1 kB 1 21-Aug-2004 20:16 128.61.42.129
java
DateModifiedPlugin.java 1.8 kB 2 21-Aug-2004 20:13 128.61.42.129
« This page (revision-4) was last changed on 21-Aug-2004 20:23 by 128.61.42.129