ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Lévy-Lambert <anto...@antbuild.com>
Subject Re: <tstamp> task error
Date Mon, 12 Jan 2004 19:14:41 GMT
Conelly, Luis (PS, GNF, Contractor) wrote:

>Hi all,
>
>	This must be such a simple error, but it seems I can't find the way to fix it.
>
>	I am trying to set the format for <tstamp> task. I just copied from the manual
the next snippet of code:
>
>    <target name="initFormatted" description="Initializes Time / Date feature Formatted">
>    <tstamp>
>      <format property="time.formatted" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/>
>    </tstamp>
>    </target>
>
>	I need prior target executed to update just the classes recently compiled, from my workdir
to my tomcat home, as showed in the snippet below:
>
>    <target name="updateCompiled" description="update *.class files to ${jBanking.classes.tomcat.home}"
>
>        <copy todir="${jBanking.classes.tomcat.home}">
>            <fileset dir="${build}" includes="**/*.class">
>                <date datetime="${tbf}" when="after"/>
>            </fileset>
>        </copy>
>    </target>
>
>      I call this target by using <antcall> call from other target, as showed below:
>
>    <target name="updateAll">
>        <!-- other stuff here-->
>        <antcall target="updateCompiled">
>            <param name="tbf" value="${time.formatted}"/>
>        </antcall>
>        <!-- other stuff here-->
>    </target>
>
>	When I try to execute this code, I got following error:
>
>---------
>BUILD FAILED
>C:\Projects\xxx xxx\jBanking\build.xml:71: Date of ${time.formatted} Cannot be parsed
correctly. It should be in MM/DD/YYYY HH:MM AM_PM format.	
>---------
>
>	I assumed something was not OK with the format. I changed the format as the error message
shows, then the 'initFormatted' target was like:
>
>    <target name="initFormatted" description="Initializes Time / Date feature Formatted">
>    <tstamp>
>      <format property="time.formatted" pattern="MM/DD/YYYY HH:MM AM_PM" unit="hour"/>
>    </tstamp>
>    </target>
>
>	But other error came up:
>
>------------
>
>BUILD FAILED
>C:\Projects\xxx xxx\jBanking\build.xml:38: java.lang.IllegalArgumentException: Illegal
pattern character 'Y'
>------------	
>
>	Then, I took a look at http://java.sun.com/j2se/1.4.1/docs/api/java/util/logging/SimpleFormatter.html
to check the params used for java.text.SimpleDateFormat class. I found that the params I was
using in the first sample of 'initFormatted' were not wrong, but not in the order showed up,
neither in the Ant manual, nor in the first error message. 
>
>	Finally, I tried:
>
>    <target name="initFormatted" description="Initializes Time / Date feature Formatted">
>    <tstamp>
>      <format property="time.formatted" pattern="MM/dd/yyyy hh:mm a" unit="hour"/>
>    </tstamp>
>    </target>	
>
>	But I got the same error, as shown below:
>
>---------
>BUILD FAILED
>C:\Projects\xxx xxx\jBanking\build.xml:71: Date of ${time.formatted} Cannot be parsed
correctly. It should be in MM/DD/YYYY HH:MM AM_PM format.	
>---------
>
>	I used -debug to look what's happening and I got zillions of lines with lots of info,
regarding on how the java files were compiled and the properties used / overriden in the <javac>
task.
>
>	With -verbose was pretty much the same thing.
>
>	Those are my settings, 
>
>-----------------
>Apache Ant version 1.6beta2 compiled on October 16 2003
>Buildfile: build.xml
>Detected Java version: 1.4 in: C:\DevTools\Java\DevEnv\JBuilder9\jdk1.4\jre
>Detected OS: Windows 2000
>-----------------	
>
>	Any clue / info / direction will be greatly appreciated. Hope the solution don't involves
any upgrade of ant version.
>
>	Thanks for your help and support
>
>	-Regards
>
>	PS. Sorry for the long mail.
>	 
>
>
>_______________________ 
>Luis G. Conelly 
>Contractor 
>
>
>  
>
Hi Luis,

the reference for date formats is : 
http://java.sun.com/j2se/1.4.1/docs/api/java/text/SimpleDateFormat.html

I have tried this :

<project name="timestamp" default="initFormatted">
    <target name="initFormatted" description="Initializes Time / Date 
feature Formatted">
    <tstamp>
      <format property="time.formatted" pattern="MM/dd/yyyy hh:mm a" 
unit="hour"/>
    </tstamp>
    <echo> ${time.formatted} </echo>
    <fileset dir="." id="myfileset">
        <date datetime="${time.formatted}" when="before"/>
    </fileset>
    <pathconvert refid="myfileset" property="myfileset" targetOS="unix"/>
    <echo> ${myfileset} </echo>
    </target>   
</project>

this works for me under ant 1.6.0 (should not be different from 
ant1.6beta2 for this functionality)

Cheers,

Antoine

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message