From aa9e0c2342b992df94941da524d8b8f13a1df840 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Wed, 3 Jan 2001 11:27:42 +0000 Subject: [PATCH] I've committed Rob's timestamp patch with a few minor changes. Submitted by: Rob Oxspring git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268390 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Tstamp.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java index 985dddfdf..be8662a0c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java @@ -64,8 +64,11 @@ import java.text.*; * * @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 @@ public class Tstamp extends Task { 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)); + } + } }