Java Doc for TimeStamp.java in  » Net » Apache-commons-net-1.4.1 » org » apache » commons » net » ntp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Apache commons net 1.4.1 » org.apache.commons.net.ntp 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.net.ntp.TimeStamp

TimeStamp
public class TimeStamp implements java.io.Serializable,Comparable(Code)
TimeStamp class represents the Network Time Protocol (NTP) timestamp as defined in RFC-1305 and SNTP (RFC-2030). It is represented as a 64-bit unsigned fixed-point number in seconds relative to 0-hour on 1-January-1900. The 32-bit low-order bits are the fractional seconds whose precision is about 200 picoseconds. Assumes overflow date when date passes MAX_LONG and reverts back to 0 is 2036 and not 1900. Test for most significant bit: if MSB=0 then 2036 basis is used otherwise 1900 if MSB=1.

Methods exist to convert NTP timestamps to and from the equivalent Java date representation, which is the number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.


author:
   Jason Mathews, MITRE Corp
version:
   $Revision: 165675 $ $Date: 2005-05-02 15:09:55 -0500 (Mon, 02 May 2005) $
See Also:   java.util.Date


Field Summary
final public static  StringNTP_DATE_FORMAT
     Default NTP date string format.
final protected static  longmsb0baseTime
    
final protected static  longmsb1baseTime
    

Constructor Summary
public  TimeStamp(long ntpTime)
     Constructs a newly allocated NTP timestamp object that represents the native 64-bit long argument.
public  TimeStamp(String s)
     Constructs a newly allocated NTP timestamp object that represents the value represented by the string in hexdecimal form (e.g.
public  TimeStamp(Date d)
     Constructs a newly allocated NTP timestamp object that represents the Java Date argument.

Method Summary
public  intcompareTo(TimeStamp anotherTimeStamp)
     Compares two Timestamps numerically.
Parameters:
  anotherTimeStamp - - the TimeStamp to be compared.
public  intcompareTo(Object o)
     Compares this TimeStamp to another Object.
protected static  longdecodeNtpHexString(String s)
     Convert NTP timestamp hexstring (e.g.
public  booleanequals(Object obj)
     Compares this object against the specified object. The result is true if and only if the argument is not null and is a Long object that contains the same long value as this object.
Parameters:
  obj - the object to compare with.
public static  TimeStampgetCurrentTime()
     Constructs a NTP timestamp object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
public  DategetDate()
     Convert NTP timestamp to Java Date object.
public  longgetFraction()
     Returns low-order 32-bits representing the fractional seconds.
public static  TimeStampgetNtpTime(long date)
     Helper method to convert Java time to NTP timestamp object. Note that Java time (milliseconds) by definition has less precision then NTP time (picoseconds) so converting Ntptime to Javatime and back to Ntptime loses precision.
public  longgetSeconds()
     Returns high-order 32-bits representing the seconds of this NTP timestamp.
public  longgetTime()
     Convert NTP timestamp to Java standard time.
public static  longgetTime(long ntpTimeValue)
     Convert 64-bit NTP timestamp to Java standard time. Note that java time (milliseconds) by definition has less precision then NTP time (picoseconds) so converting NTP timestamp to java time and back to NTP timestamp loses precision.
public  inthashCode()
     Computes a hashcode for this Timestamp.
public  longntpValue()
     Returns the value of this Timestamp as a long value.
public static  TimeStampparseNtpString(String s)
     Parses the string argument as a NTP hexidecimal timestamp representation string (e.g.
public  StringtoDateString()
     Converts this TimeStamp object to a String of the form:
 EEE, MMM dd yyyy HH:mm:ss.SSS
See java.text.SimpleDataFormat for code descriptions.
protected static  longtoNtpTime(long t)
     Converts Java time to 64-bit NTP time representation.
public  StringtoString()
     Converts this TimeStamp object to a String. The NTP timestamp 64-bit long value is represented as hex string with seconds separated by fractional seconds by a decimal point; e.g.
public static  StringtoString(long ntpTime)
     Converts 64-bit NTP timestamp value to a String. The NTP timestamp value is represented as hex string with seconds separated by fractional seconds by a decimal point; e.g.
public  StringtoUTCString()
     Converts this TimeStamp object to a String of the form:
 EEE, MMM dd yyyy HH:mm:ss.SSS UTC
See java.text.SimpleDataFormat for code descriptions.

Field Detail
NTP_DATE_FORMAT
final public static String NTP_DATE_FORMAT(Code)
Default NTP date string format. E.g. Fri, Sep 12 2003 21:06:23.860. See java.text.SimpleDateFormat for code descriptions.



msb0baseTime
final protected static long msb0baseTime(Code)
baseline NTP time if bit-0=0 -> 7-Feb-2036 @ 06:28:16 UTC



msb1baseTime
final protected static long msb1baseTime(Code)
baseline NTP time if bit-0=1 -> 1-Jan-1900 @ 01:00:00 UTC




Constructor Detail
TimeStamp
public TimeStamp(long ntpTime)(Code)
Constructs a newly allocated NTP timestamp object that represents the native 64-bit long argument.



TimeStamp
public TimeStamp(String s) throws NumberFormatException(Code)
Constructs a newly allocated NTP timestamp object that represents the value represented by the string in hexdecimal form (e.g. "c1a089bd.fc904f6d").
throws:
  NumberFormatException - - if the string does not contain a parsable timestamp.



TimeStamp
public TimeStamp(Date d)(Code)
Constructs a newly allocated NTP timestamp object that represents the Java Date argument.
Parameters:
  d - - the Date to be represented by the Timestamp object.




Method Detail
compareTo
public int compareTo(TimeStamp anotherTimeStamp)(Code)
Compares two Timestamps numerically.
Parameters:
  anotherTimeStamp - - the TimeStamp to be compared. the value 0 if the argument TimeStamp is equal tothis TimeStamp; a value less than 0 if this TimeStampis numerically less than the TimeStamp argument; and avalue greater than 0 if this TimeStamp isnumerically greater than the TimeStamp argument(signed comparison).



compareTo
public int compareTo(Object o)(Code)
Compares this TimeStamp to another Object. If the Object is a TimeStamp, this function behaves like compareTo(TimeStamp). Otherwise, it throws a ClassCastException (as TimeStamps are comparable only to other TimeStamps).
Parameters:
  o - the Object to be compared. the value 0 if the argument is a TimeStampnumerically equal to this TimeStamp; a value less than0 if the argument is a TimeStamp numericallygreater than this TimeStamp; and a value greater than0 if the argument is a TimeStamp numericallyless than this TimeStamp.
exception:
  ClassCastException - if the argument is not aTimeStamp.
See Also:   java.lang.Comparable



decodeNtpHexString
protected static long decodeNtpHexString(String s) throws NumberFormatException(Code)
Convert NTP timestamp hexstring (e.g. "c1a089bd.fc904f6d") to the NTP 64-bit unsigned fixed-point number. NTP 64-bit timestamp value.
throws:
  NumberFormatException - - if the string does not contain a parsable timestamp.



equals
public boolean equals(Object obj)(Code)
Compares this object against the specified object. The result is true if and only if the argument is not null and is a Long object that contains the same long value as this object.
Parameters:
  obj - the object to compare with. true if the objects are the same;false otherwise.



getCurrentTime
public static TimeStamp getCurrentTime()(Code)
Constructs a NTP timestamp object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond. NTP timestamp object set to the current time.
See Also:   java.lang.System.currentTimeMillis



getDate
public Date getDate()(Code)
Convert NTP timestamp to Java Date object. NTP Timestamp in Java Date



getFraction
public long getFraction()(Code)
Returns low-order 32-bits representing the fractional seconds. fractional seconds represented by this NTP timestamp.



getNtpTime
public static TimeStamp getNtpTime(long date)(Code)
Helper method to convert Java time to NTP timestamp object. Note that Java time (milliseconds) by definition has less precision then NTP time (picoseconds) so converting Ntptime to Javatime and back to Ntptime loses precision. For example, Tue, Dec 17 2002 09:07:24.810 is represented by a single Java-based time value of f22cd1fc8a, but its NTP equivalent are all values from c1a9ae1c.cf5c28f5 to c1a9ae1c.cf9db22c.
Parameters:
  date - the milliseconds since January 1, 1970, 00:00:00 GMT. NTP timestamp object at the specified date.



getSeconds
public long getSeconds()(Code)
Returns high-order 32-bits representing the seconds of this NTP timestamp. seconds represented by this NTP timestamp.



getTime
public long getTime()(Code)
Convert NTP timestamp to Java standard time. NTP Timestamp in Java time



getTime
public static long getTime(long ntpTimeValue)(Code)
Convert 64-bit NTP timestamp to Java standard time. Note that java time (milliseconds) by definition has less precision then NTP time (picoseconds) so converting NTP timestamp to java time and back to NTP timestamp loses precision. For example, Tue, Dec 17 2002 09:07:24.810 EST is represented by a single Java-based time value of f22cd1fc8a, but its NTP equivalent are all values ranging from c1a9ae1c.cf5c28f5 to c1a9ae1c.cf9db22c.
Parameters:
  ntpTimeValue - the number of milliseconds since January 1, 1970, 00:00:00 GMTrepresented by this NTP timestamp value.



hashCode
public int hashCode()(Code)
Computes a hashcode for this Timestamp. The result is the exclusive OR of the two halves of the primitive long value represented by this TimeStamp object. That is, the hashcode is the value of the expression:
 (int)(this.ntpValue()^(this.ntpValue() >>> 32))
 
a hash code value for this object.



ntpValue
public long ntpValue()(Code)
Returns the value of this Timestamp as a long value. the 64-bit long value represented by this object.



parseNtpString
public static TimeStamp parseNtpString(String s) throws NumberFormatException(Code)
Parses the string argument as a NTP hexidecimal timestamp representation string (e.g. "c1a089bd.fc904f6d").
Parameters:
  s - - hexstring. the Timestamp represented by the argument in hexidecimal.
throws:
  NumberFormatException - - if the string does not contain a parsable timestamp.



toDateString
public String toDateString()(Code)
Converts this TimeStamp object to a String of the form:
 EEE, MMM dd yyyy HH:mm:ss.SSS
See java.text.SimpleDataFormat for code descriptions. a string representation of this date.



toNtpTime
protected static long toNtpTime(long t)(Code)
Converts Java time to 64-bit NTP time representation.
Parameters:
  t - Java time NTP timestamp representation of Java time value.



toString
public String toString()(Code)
Converts this TimeStamp object to a String. The NTP timestamp 64-bit long value is represented as hex string with seconds separated by fractional seconds by a decimal point; e.g. c1a089bd.fc904f6d <=> Tue, Dec 10 2002 10:41:49.986 NTP timestamp 64-bit long value as hex string with secondsseparated by fractional seconds.



toString
public static String toString(long ntpTime)(Code)
Converts 64-bit NTP timestamp value to a String. The NTP timestamp value is represented as hex string with seconds separated by fractional seconds by a decimal point; e.g. c1a089bd.fc904f6d <=> Tue, Dec 10 2002 10:41:49.986 NTP timestamp 64-bit long value as hex string with secondsseparated by fractional seconds.



toUTCString
public String toUTCString()(Code)
Converts this TimeStamp object to a String of the form:
 EEE, MMM dd yyyy HH:mm:ss.SSS UTC
See java.text.SimpleDataFormat for code descriptions. a string representation of this date in UTC.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.