Saturday, June 13, 2009

java tips

Format number to two digits

System.out.println(new DecimalFormat("00").format(8));
System.out.println(new DecimalFormat("00").format(18));

Invoke just before the appliction shutsdown
static {
//add runtime shutdown hook in a runnable
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
//...
}
});
}

No comments:

Post a Comment