How could I stick a build date in a page fragment?

Just want to know the simplest way to put a build date in a label that's in a site header page fragment.
[112 byte] By [starwood4] at [2007-11-26 6:50:48]
# 1
Probably, you should write the build date to a file and then open the file in the init() method and set the content as text for the label component in the page fragment.- Winston http://blogs.sun.com/roller/page/winston?catname=Creator
wjprakash at 2007-7-6 15:17:25 > top of Java-index,Development Tools,Java Tools...
# 2

You can use Ant build tool (http://ant.apache.org/) to create property file with current date, include it in jar file and then read this date from file.

Ant script to create property file with current date will look like:

<propertyfile file="resources/builddate.properties">

<entry key="builddate" value="now" type="date" pattern="yyyy.MM.dd HH.mm.ss"/>

</propertyfile>

And here is java code to read build date.

import java.io.IOException;

import java.io.InputStream;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Properties;

import org.apache.log4j.Logger;

public class ProgramUtil {

static Logger log = Logger.getLogger(ProgramUtil.class);

public static Date getBuildDate() {

Date retValue = null;

try {

Properties p = new Properties();

InputStream is = ProgramUtil.class.getResourceAsStream("/builddate.properties");

if (is != null) {

p.load(is);

String buildDateString = p.getProperty("builddate");

try {

retValue = buildDateString == null ? null : new SimpleDateFormat("yyyy.MM.dd HH.mm.ss").parse(buildDateString);

} catch (ParseException e) {

log.error("Error", e);

}

}

else {

log.error("Resource builddate.properties is not found");

}

} catch (IOException e) {

log.error("Error", e);

}

return retValue;

}

}

ivanholub at 2007-7-6 15:17:25 > top of Java-index,Development Tools,Java Tools...