You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@apache.org on 2001/01/03 12:27:45 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Tstamp.java
conor 01/01/03 03:27:44
Modified: src/main/org/apache/tools/ant/taskdefs Tstamp.java
Log:
I've committed Rob's timestamp patch with a few minor changes.
Submitted by: Rob Oxspring <ro...@yahoo.com>
Revision Changes Path
1.6 +44 -0 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
Index: Tstamp.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tstamp.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Tstamp.java 2000/09/14 07:19:52 1.5
+++ Tstamp.java 2001/01/03 11:27:42 1.6
@@ -64,8 +64,11 @@
*
* @author costin@dnt.ro
* @author stefano@apache.org
+ * @author roxspring@yahoo.com
*/
public class Tstamp extends Task {
+
+ private Vector customFormats = new Vector();
public void execute() throws BuildException {
try {
@@ -79,8 +82,49 @@
SimpleDateFormat today = new SimpleDateFormat ("MMMM d yyyy", Locale.US);
project.setProperty("TODAY", today.format(d));
+
+ Enumeration i = customFormats.elements();
+ while(i.hasMoreElements())
+ {
+ CustomFormat cts = (CustomFormat)i.nextElement();
+ cts.execute(project,d);
+ }
+
} catch (Exception e) {
throw new BuildException(e);
+ }
+ }
+
+ public CustomFormat createFormat()
+ {
+ CustomFormat cts = new CustomFormat();
+ customFormats.addElement(cts);
+ return cts;
+ }
+
+ public class CustomFormat
+ {
+ private String propertyName;
+ private String pattern;
+
+ public CustomFormat()
+ {
+ }
+
+ public void setProperty(String propertyName)
+ {
+ this.propertyName = propertyName;
+ }
+
+ public void setPattern(String pattern)
+ {
+ this.pattern = pattern;
+ }
+
+ public void execute(Project project, Date date)
+ {
+ SimpleDateFormat sdf = new SimpleDateFormat (pattern);
+ project.setProperty(propertyName, sdf.format(date));
}
}
}