This isn't really worthy of even being posted, but oh well. Basically, it has a timestamp() function to get the current timestamp of the system clock. Anyone know an easy way of doing local time?
/**
This is a test class for my timestamp() method, described below
@author Joe[x86]
TODO: Time offset
*/
public class Timestamp
{
/** Damn Java's main() method for being static! */
public static void main(String args[]) { new Timestamp(); }
public Timestamp() { System.out.println(timestamp()); }
/**
Get's the current system time
*/
public String timestamp()
{
long mil = System.currentTimeMillis();
long sec = (mil / 1000) % 60;
long min = (mil / 60000) % 60;
long hr = (mil / 360000) % 24;
mil %= 1000;
return padLong(hr, 2) + ":" + padLong(min, 2) + ":" + padLong(sec, 2) + "." + padLong(mil, 3);
}
/**
Casts a long into a String and pads it to a specific length
@param l The long
@param length Length to pad it to
*/
private String padLong(long l, int length)
{
String ret = Long.toString(l);
for(int i = 0; i < length - ret.length(); i++)
{
ret = "0" + ret;
}
return ret;
}
}