|
xmlBlaster 2.1.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xmlBlaster.util.Timestamp
public class Timestamp
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
<timestamp nanos='1013346248150000001'>
2002-02-10 14:04:08.150000001
</timestamp>
or
<timestamp nanos='1013346248150000001'/>
TimestampTest,
Serialized Form| Field Summary | |
|---|---|
static int |
BILLION
|
private static long |
lastMillis
|
static int |
MILLION
|
private static int |
nanoCounter
|
private static long |
serialVersionUID
|
private java.lang.String |
strFormat
Cache for string representation |
protected java.lang.String |
tagName
You may overwrite the tag name for XML dumps in derived classes, defaults to <timestamp ... |
private long |
timestamp
The timestamp in nanoseconds |
private java.lang.Long |
timestampLong
|
| Constructor Summary | |
|---|---|
Timestamp()
Constructs a current timestamp which is guaranteed to be unique in time for this JVM |
|
Timestamp(long nanos)
Create a Timestamp with given nanoseconds since 1970 |
|
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object obj)
Compares two Timestamps for ordering. |
boolean |
equals(java.lang.Object obj)
Compares this object against the specified object. |
boolean |
equals(Timestamp ts)
Tests to see if this Timestamp object is
equal to the given Timestamp object. |
long |
getMillis()
You can use this value for java.util.Date(millis) |
int |
getMillisOnly()
The milli part only |
int |
getNanosOnly()
The nano part only |
long |
getTime()
You can use this value for java.util.Date(millis) |
long |
getTimestamp()
|
java.lang.Long |
getTimestampLong()
We cache a Long object for reuse (helpful when used as a key in a map). |
static void |
main(java.lang.String[] args)
Test only. |
static java.lang.String |
millisToNice(long millis)
Convert milliseconds to some more human readable representation. |
static void |
sleep(long millis)
Stop execution for some given milliseconds. |
private static Timestamp |
test(java.lang.StringBuffer buf)
Test only |
private static void |
testToString()
Test only |
private static void |
testToXml(boolean literal)
Test only |
private static void |
testValueOf()
Test only |
java.lang.String |
toString()
Timestamp in JDBC Timestamp escape format (human readable). |
java.lang.String |
toXml()
|
java.lang.String |
toXml(java.lang.String extraOffset)
|
java.lang.String |
toXml(java.lang.String extraOffset,
boolean literal)
Dump state of this object into a XML ASCII string. |
static Timestamp |
valueOf(java.lang.String s)
Converts a String object in JDBC timestamp escape format to a
Timestamp value. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
public static final int MILLION
public static final int BILLION
private static int nanoCounter
private static long lastMillis
private final long timestamp
private transient java.lang.Long timestampLong
private transient java.lang.String strFormat
protected java.lang.String tagName
| Constructor Detail |
|---|
public Timestamp()
java.lang.RuntimeException - on overflow (never happens :-=)public Timestamp(long nanos)
Date| Method Detail |
|---|
public final long getTimestamp()
public final java.lang.Long getTimestampLong()
public final int getNanosOnly()
public final int getMillisOnly()
public final long getMillis()
getTime(),
Datepublic final long getTime()
getMillis(),
Datepublic java.lang.String toString()
toString in class java.lang.Objectpublic static Timestamp valueOf(java.lang.String s)
String object in JDBC timestamp escape format to a
Timestamp value.
s - timestamp in format yyyy-mm-dd hh:mm:ss.fffffffff
Timestamp value
java.lang.IllegalArgumentException - if the given argument
does not have the format yyyy-mm-dd hh:mm:ss.fffffffffpublic int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparablets - The Timestamp to be compared.
0 if the argument Timestamp is equal to
this Timestamp; a value less than 0 if this
Timestamp is before the Timestamp argument; and a value greater than
0 if this Timestamp is after the Timestamp argument.public boolean equals(Timestamp ts)
Timestamp object is
equal to the given Timestamp object.
stamp - the Timestamp value to compare with
true if the given Timestamp
object is equal to this Timestamp object;
false otherwisepublic boolean equals(java.lang.Object obj)
true if and only if the argument is
not null and is a Long object that
contains the same long value as this object.
equals in class java.lang.Objectobj - the object to compare with.
true if the objects are the same;
false otherwise.public final java.lang.String toXml()
public final java.lang.String toXml(java.lang.String extraOffset)
public final java.lang.String toXml(java.lang.String extraOffset,
boolean literal)
extraOffset - indenting of tags for nice outputliteral - true -> show human readable format as well (JDBC escape format)
"2002-02-10 10:52:40.879456789"
public static final java.lang.String millisToNice(long millis)
millis - An amount of elapsed milliseconds
public static void sleep(long millis)
millis - amount of milliseconds to waitpublic static void main(java.lang.String[] args)
javac -g -d $XMLBLASTER_HOME/classes Timestamp.java
java org.xmlBlaster.util.Timestamp
Dump a nanosecond 'long' to a string representation:
java org.xmlBlaster.util.Timestamp 1076677832527000001
Dump a a string representation to a nanosecond 'long':
java org.xmlBlaster.util.Timestamp "2004-02-13 14:10:32.527000001"
private static final Timestamp test(java.lang.StringBuffer buf)
private static final void testToString()
private static final void testValueOf()
private static final void testToXml(boolean literal)
|
xmlBlaster 2.1.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||