Browse Source

I've committed Rob's timestamp patch with a few minor changes.

Submitted by:	Rob Oxspring <roxspring@yahoo.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268390 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
aa9e0c2342
1 changed files with 44 additions and 0 deletions
  1. +44
    -0
      src/main/org/apache/tools/ant/taskdefs/Tstamp.java

+ 44
- 0
src/main/org/apache/tools/ant/taskdefs/Tstamp.java View File

@@ -64,8 +64,11 @@ import java.text.*;
* *
* @author costin@dnt.ro * @author costin@dnt.ro
* @author stefano@apache.org * @author stefano@apache.org
* @author roxspring@yahoo.com
*/ */
public class Tstamp extends Task { public class Tstamp extends Task {
private Vector customFormats = new Vector();


public void execute() throws BuildException { public void execute() throws BuildException {
try { try {
@@ -79,8 +82,49 @@ public class Tstamp extends Task {


SimpleDateFormat today = new SimpleDateFormat ("MMMM d yyyy", Locale.US); SimpleDateFormat today = new SimpleDateFormat ("MMMM d yyyy", Locale.US);
project.setProperty("TODAY", today.format(d)); 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) { } catch (Exception e) {
throw new BuildException(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));
}
}
} }

Loading…
Cancel
Save