1

I need to create a custom stamp for the day of the week, which is to be appended to the filename.

Suppose If it is sunday , the value of the stamp must be "1", same way if its monday the value of the stamp must be "2".

Is this possible in MQFTE using Ant Script???

trilawney
  • 1,786
  • 6
  • 28
  • 36

1 Answers1

1

You can't do this directly with standard TStamp task. That allows you to format your timestamp using patterns defined in SimpleDateFormat, and there is no format symbol for day of week as a number.

I guess you could write a custom TStamp task.

However, this works.

Create a set of properties files, named using 3-letter day name:

$ find daysOfWeek/
daysOfWeek/
daysOfWeek/Fri.properties
daysOfWeek/Mon.properties
daysOfWeek/Sat.properties
daysOfWeek/Sun.properties
daysOfWeek/Thu.properties
daysOfWeek/Tue.properties
daysOfWeek/Wed.properties

In each file, define a single property for the corresponding day number, e.g.

$ cat daysOfWeek/Thu.properties
day.num=5

In your build script, first get a property matching today's day name, then load the corresponding properties file, then you can reference the day.num property.

<project>

<tstamp>
  <format property="day.name" pattern="E" locale="en/US"/>
</tstamp>

<property file="daysOfWeek/${day.name}.properties"/>

<echo message="${day.name}"/>
<echo message="${day.num}"/>

</project>

Output today (Thursday) is

$ ant
Buildfile: build.xml
     [echo] Thu
     [echo] 5

BUILD SUCCESSFUL
Total time: 0 seconds
ewan.chalmers
  • 16,145
  • 43
  • 60