@@ -115,14 +115,14 @@ public class Tstamp extends Task {
}
}
SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd");
SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd");
getProject(). setNew Property(prefix + "DSTAMP", dstamp.format(d));
setProperty("DSTAMP", dstamp.format(d));
SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm");
SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm");
getProject(). setNew Property(prefix + "TSTAMP", tstamp.format(d));
setProperty("TSTAMP", tstamp.format(d));
SimpleDateFormat today
SimpleDateFormat today
= new SimpleDateFormat ("MMMM d yyyy", Locale.US);
= new SimpleDateFormat ("MMMM d yyyy", Locale.US);
getProject(). setNew Property(prefix + "TODAY", today.format(d));
setProperty("TODAY", today.format(d));
} catch (Exception e) {
} catch (Exception e) {
throw new BuildException(e);
throw new BuildException(e);
@@ -134,11 +134,19 @@ public class Tstamp extends Task {
* @return a ready to fill-in format
* @return a ready to fill-in format
*/
*/
public CustomFormat createFormat() {
public CustomFormat createFormat() {
CustomFormat cts = new CustomFormat(prefix );
CustomFormat cts = new CustomFormat();
customFormats.addElement(cts);
customFormats.addElement(cts);
return cts;
return cts;
}
}
/**
* helper that encapsulates prefix logic and property setting
* policy (i.e. we use setNewProperty instead of setProperty).
*/
private void setProperty(String name, String value) {
getProject().setNewProperty(prefix + name, value);
}
/**
/**
* This nested element that allows a property to be set
* This nested element that allows a property to be set
* to the current date and time in a given format.
* to the current date and time in a given format.
@@ -157,14 +165,11 @@ public class Tstamp extends Task {
private String variant;
private String variant;
private int offset = 0;
private int offset = 0;
private int field = Calendar.DATE;
private int field = Calendar.DATE;
private String prefix = "";
/**
/**
* Create a format with the current prefix
* @param prefix
* Create a format
*/
*/
public CustomFormat(String prefix) {
this.prefix = prefix;
public CustomFormat() {
}
}
/**
/**
@@ -172,7 +177,7 @@ public class Tstamp extends Task {
* @param propertyName
* @param propertyName
*/
*/
public void setProperty(String propertyName) {
public void setProperty(String propertyName) {
this.propertyName = prefix + pr opertyName;
this.propertyName = propertyName;
}
}
/**
/**
@@ -306,7 +311,7 @@ public class Tstamp extends Task {
if (timeZone != null){
if (timeZone != null){
sdf.setTimeZone(timeZone);
sdf.setTimeZone(timeZone);
}
}
project.setNew Property(propertyName, sdf.format(date));
Tstamp.this.set Property(propertyName, sdf.format(date));
}
}
}
}