@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
@@ -57,35 +57,31 @@ package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.*;
import java.io.*;
import java.util.*;
import java.text.*;
/**
* Will set TSTAMP and DSTAMP
* Sets TSTAMP, DSTAMP and TODAY
*
* @author costin@dnt.ro
* @author stefano@apache.org
*/
public class Tstamp extends Task {
public void execute() throws BuildException {
try {
Calendar d=Calendar.getInstance();
StringBuffer tstamp=new StringBuffer();
tstamp.append( d.get(Calendar.YEAR));
if(d.get(Calendar.MONTH) < 9) tstamp.append("0");
tstamp.append( 1+d.get(Calendar.MONTH));
if( d.get(Calendar.DAY_OF_MONTH) < 10 ) tstamp.append("0");
tstamp.append(d.get(Calendar.DAY_OF_MONTH));
project.setProperty( "DSTAMP" , tstamp.toString());
if( d.get(Calendar.HOUR_OF_DAY) < 10 ) tstamp.append("0");
tstamp.append( d.get(Calendar.HOUR_OF_DAY));
if( d.get(Calendar.MINUTE) < 10 ) tstamp.append("0");
tstamp.append(d.get(Calendar.MINUTE));
project.setProperty( "TSTAMP" , tstamp.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
try {
Date d = new Date();
SimpleDateFormat dstamp = new SimpleDateFormat ("yyyymmdd");
project.setProperty("DSTAMP", dstamp.format(d));
SimpleDateFormat tstamp = new SimpleDateFormat ("hhmm");
project.setProperty("TSTAMP", tstamp.format(d));
SimpleDateFormat today = new SimpleDateFormat ("MMMM d yyyy", Locale.US);
project.setProperty("TODAY", today.format(d));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}