[kaffe] Funny date formats from ant

Jaco Greeff kaffe at puxedo.org
Tue Jul 15 22:45:01 PDT 2003


Hi,

I've been successfully (at least for my build scripts) running ant 1.5.3 
with Kaffe. I have found a small cosmetic discrepancy in displaying the 
final elapsed build time. What I've done is to liberally copy the 
offending code from ant (attached as test.java) to provide you with a 
test case. Basically this is the outputs from both Sun JDK and Kaffe:

[jaco at grumpy jaco]$ javac test/test.java
[jaco at grumpy jaco]$ java test/test
Total time: 7 minutes 36 seconds (456789)
[jaco at grumpy jaco]$ /usr/local/kaffe/bin/kaffe test/test
Total time: {0,number} minutes {1,number} seconds (456789)
[jaco at grumpy jaco]$

Greetings,
Jaco
-------------- next part --------------
package test;

import java.text.ChoiceFormat;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class test {

	public static final String ISO8601_DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
	public static final String ISO8601_DATE_PATTERN = "yyyy-MM-dd";
	public static final String ISO8601_TIME_PATTERN = "HH:mm:ss";
	public static final DateFormat DATE_HEADER_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ", Locale.US);
	private static final MessageFormat MINUTE_SECONDS = new MessageFormat("{0}{1}");
	private static final double[] LIMITS = {0, 1, 2};
	private static final String[] MINUTES_PART = {"", "1 minute ", "{0,number} minutes "};
	private static final String[] SECONDS_PART = {"0 seconds", "1 second", "{1,number} seconds"};
	private static final ChoiceFormat MINUTES_FORMAT = new ChoiceFormat(LIMITS, MINUTES_PART);
	private static final ChoiceFormat SECONDS_FORMAT = new ChoiceFormat(LIMITS, SECONDS_PART);

	static {
		MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
		MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
	}

	public static String formatElapsedTime(long millis) {
		long seconds = millis / 1000;
		long minutes = seconds / 60;
		Object[] args = {new Long(minutes), new Long(seconds % 60)};
		return MINUTE_SECONDS.format(args);
	}

	public static void main(String[] args) {
		long elapsedTime = 456789;
		System.out.print("Total time: ");
		System.out.print(formatElapsedTime(elapsedTime));
		System.out.println(" (" + elapsedTime + ")");
	}
}


More information about the kaffe mailing list