High performing timestamp class, time elapsed since 1970, the nanos are simulated as a unique counter.
The counter is rewound on any millisecond step.
Timestamp objects are immutable - a Timstamp can not be changed once it is created.
Guarantees that any created Timestamp instance is unique in the current Java Virtual Machine (and Classloader).
Fails only if
- a CPU can create more than 999999 Timestamp instances per millisecond
- In ~ 288 years when Long.MAX_VALUE = 9223372036854775807 overflows (current value is 1013338358124000008)
A typical output is:
- toString()=2002-02-10 11:57:51.804000001
- getTimestamp()=1013338671804000001
- getMillis()=1013338671804
- getMillisOnly()=804
- getNanosOnly()=804000001
Performance hints (600 MHz Intel PC, Linux 2.4.10, JDK 1.3.1):
- new Timestamp() 1.2 micro seconds
- toString() 55 micro seconds the first time, further access 0.1 micro seconds
- valueOf() 19 micro seconds
- toXml("", false) 16 micro seconds
- toXml("", true) 17 micro seconds
XML representation:
<timestamp nanos='1013346248150000001'> 2002-02-10 14:04:08.150000001 </timestamp>
or
<timestamp nanos='1013346248150000001'/>
@author
Marcel Ruff
@see org.xmlBlaster.test.classtest.TimestampTest