Java Doc for UniversalTimeScale.java in  » Internationalization-Localization » icu4j » com » ibm » icu » util » 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 » Internationalization Localization » icu4j » com.ibm.icu.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ibm.icu.util.UniversalTimeScale

UniversalTimeScale
final public class UniversalTimeScale (Code)
There are quite a few different conventions for binary datetime, depending on different platforms and protocols. Some of these have severe drawbacks. For example, people using Unix time (seconds since Jan 1, 1970, usually in a 32-bit integer) think that they are safe until near the year 2038. But cases can and do arise where arithmetic manipulations causes serious problems. Consider the computation of the average of two datetimes, for example: if one calculates them with averageTime = (time1 + time2)/2, there will be overflow even with dates beginning in 2004. Moreover, even if these problems don't occur, there is the issue of conversion back and forth between different systems.

Binary datetimes differ in a number of ways: the datatype, the unit, and the epoch (origin). We refer to these as time scales.

ICU implements a universal time scale that is similar to the .NET framework's System.DateTime. The universal time scale is a 64-bit integer that holds ticks since midnight, January 1st, 0001. (One tick is 100 nanoseconds.) Negative values are supported. This has enough range to guarantee that calculations involving dates around the present are safe.

The universal time scale always measures time according to the proleptic Gregorian calendar. That is, the Gregorian calendar's leap year rules are used for all times, even before 1582 when it was introduced. (This is different from the default ICU calendar which switches from the Julian to the Gregorian calendar in 1582. See GregorianCalendar.setGregorianChange() and ucal_setGregorianChange().)

ICU provides conversion functions to and from all other major time scales, allowing datetimes in any time scale to be converted to the universal time scale, safely manipulated, and converted back to any other datetime time scale.

For more details and background, see the Universal Time Scale chapter in the ICU User Guide.



Field Summary
final public static  intDB2_TIME
     Used in DB2.
final public static  intDOTNET_DATE_TIME
     Used in the .NET framework's System.DateTime structure. Data is a long.
final public static  intEPOCH_OFFSET_MINUS_1_VALUE
     The constant used to select the epoch offset minus one value for a time scale. NOTE: This is an internal value.
final public static  intEPOCH_OFFSET_PLUS_1_VALUE
     The constant used to select the epoch plus one value for a time scale. NOTE: This is an internal value.
final public static  intEPOCH_OFFSET_VALUE
     The constant used to select the epoch offset value for a time scale.
final public static  intEXCEL_TIME
     Used in Excel.
final public static  intFROM_MAX_VALUE
     The constant used to select the maximum from value for a time scale.
final public static  intFROM_MIN_VALUE
     The constant used to select the minimum from value for a time scale.
final public static  intICU4C_TIME
     Used in the ICU4C.
final public static  intJAVA_TIME
     Used in the JDK.
final public static  intMAC_OLD_TIME
     Used in older Macintosh systems.
final public static  intMAC_TIME
     Used in the JDK.
final public static  intMAX_ROUND_VALUE
     The constant used to select the maximum safe rounding value for a time scale. NOTE: This is an internal value.
final public static  intMAX_SCALE
     This is the first unused time scale value.
final public static  intMAX_SCALE_VALUE
     The number of time scale values. NOTE: This is an internal value.
final public static  intMIN_ROUND_VALUE
     The constant used to select the minimum safe rounding value for a time scale. NOTE: This is an internal value.
final public static  intTO_MAX_VALUE
     The constant used to select the maximum to value for a time scale.
final public static  intTO_MIN_VALUE
     The constant used to select the minimum to value for a time scale.
final public static  intUNITS_ROUND_VALUE
     The constant used to select the units round value for a time scale. NOTE: This is an internal value.
final public static  intUNITS_VALUE
     The constant used to select the units value for a time scale.
final public static  intUNIX_TIME
     Used in Unix systems.
final public static  intWINDOWS_FILE_TIME
     Used in Windows for file times.


Method Summary
public static  BigDecimalbigDecimalFrom(double otherTime, int timeScale)
     Convert a double datetime from the given time scale to the universal time scale.
public static  BigDecimalbigDecimalFrom(long otherTime, int timeScale)
     Convert a long datetime from the given time scale to the universal time scale.
public static  BigDecimalbigDecimalFrom(BigDecimal otherTime, int timeScale)
     Convert a BigDecimal datetime from the given time scale to the universal time scale.
public static  longfrom(long otherTime, int timeScale)
     Convert a long datetime from the given time scale to the universal time scale.
public static  longgetTimeScaleValue(int scale, int value)
     Get a value associated with a particular time scale.
public static  BigDecimaltoBigDecimal(long universalTime, int timeScale)
     Convert a datetime from the universal time scale to a BigDecimal in the given time scale.
public static  BigDecimaltoBigDecimal(BigDecimal universalTime, int timeScale)
     Convert a datetime from the universal time scale to a BigDecimal in the given time scale.
public static  BigDecimaltoBigDecimalTrunc(BigDecimal universalTime, int timeScale)
     Convert a time in the Universal Time Scale into another time scale.
public static  longtoLong(long universalTime, int timeScale)
     Convert a datetime from the universal time scale stored as a BigDecimal to a long in the given time scale. Since this calculation requires a divide, we must round.

Field Detail
DB2_TIME
final public static int DB2_TIME(Code)
Used in DB2. Data is a ?unknown?. Value is days since December 31, 1899.



DOTNET_DATE_TIME
final public static int DOTNET_DATE_TIME(Code)
Used in the .NET framework's System.DateTime structure. Data is a long. Value is ticks (1 tick == 100 nanoseconds) since January 1, 0001.



EPOCH_OFFSET_MINUS_1_VALUE
final public static int EPOCH_OFFSET_MINUS_1_VALUE(Code)
The constant used to select the epoch offset minus one value for a time scale. NOTE: This is an internal value. DO NOT USE IT. May not actually be equal to the epoch offset value minus one.
See Also:   UniversalTimeScale.getTimeScaleValue



EPOCH_OFFSET_PLUS_1_VALUE
final public static int EPOCH_OFFSET_PLUS_1_VALUE(Code)
The constant used to select the epoch plus one value for a time scale. NOTE: This is an internal value. DO NOT USE IT. May not actually be equal to the epoch offset value plus one.
See Also:   UniversalTimeScale.getTimeScaleValue



EPOCH_OFFSET_VALUE
final public static int EPOCH_OFFSET_VALUE(Code)
The constant used to select the epoch offset value for a time scale.
See Also:   UniversalTimeScale.getTimeScaleValue



EXCEL_TIME
final public static int EXCEL_TIME(Code)
Used in Excel. Data is a ?unknown?. Value is days since December 31, 1899.



FROM_MAX_VALUE
final public static int FROM_MAX_VALUE(Code)
The constant used to select the maximum from value for a time scale.
See Also:   UniversalTimeScale.getTimeScaleValue



FROM_MIN_VALUE
final public static int FROM_MIN_VALUE(Code)
The constant used to select the minimum from value for a time scale.
See Also:   UniversalTimeScale.getTimeScaleValue



ICU4C_TIME
final public static int ICU4C_TIME(Code)
Used in the ICU4C. Data is a double. Value is milliseconds since January 1, 1970.



JAVA_TIME
final public static int JAVA_TIME(Code)
Used in the JDK. Data is a long. Value is milliseconds since January 1, 1970.



MAC_OLD_TIME
final public static int MAC_OLD_TIME(Code)
Used in older Macintosh systems. Data is an int. Value is seconds since January 1, 1904.



MAC_TIME
final public static int MAC_TIME(Code)
Used in the JDK. Data is a double. Value is milliseconds since January 1, 2001.



MAX_ROUND_VALUE
final public static int MAX_ROUND_VALUE(Code)
The constant used to select the maximum safe rounding value for a time scale. NOTE: This is an internal value. DO NOT USE IT.
See Also:   UniversalTimeScale.getTimeScaleValue



MAX_SCALE
final public static int MAX_SCALE(Code)
This is the first unused time scale value.



MAX_SCALE_VALUE
final public static int MAX_SCALE_VALUE(Code)
The number of time scale values. NOTE: This is an internal value. DO NOT USE IT.
See Also:   UniversalTimeScale.getTimeScaleValue



MIN_ROUND_VALUE
final public static int MIN_ROUND_VALUE(Code)
The constant used to select the minimum safe rounding value for a time scale. NOTE: This is an internal value. DO NOT USE IT.
See Also:   UniversalTimeScale.getTimeScaleValue



TO_MAX_VALUE
final public static int TO_MAX_VALUE(Code)
The constant used to select the maximum to value for a time scale.
See Also:   UniversalTimeScale.getTimeScaleValue



TO_MIN_VALUE
final public static int TO_MIN_VALUE(Code)
The constant used to select the minimum to value for a time scale.
See Also:   UniversalTimeScale.getTimeScaleValue



UNITS_ROUND_VALUE
final public static int UNITS_ROUND_VALUE(Code)
The constant used to select the units round value for a time scale. NOTE: This is an internal value. DO NOT USE IT.
See Also:   UniversalTimeScale.getTimeScaleValue



UNITS_VALUE
final public static int UNITS_VALUE(Code)
The constant used to select the units value for a time scale.



UNIX_TIME
final public static int UNIX_TIME(Code)
Used in Unix systems. Data is an int or a long. Value is seconds since January 1, 1970.



WINDOWS_FILE_TIME
final public static int WINDOWS_FILE_TIME(Code)
Used in Windows for file times. Data is a long. Value is ticks (1 tick == 100 nanoseconds) since January 1, 1601.





Method Detail
bigDecimalFrom
public static BigDecimal bigDecimalFrom(double otherTime, int timeScale)(Code)
Convert a double datetime from the given time scale to the universal time scale. All calculations are done using BigDecimal to guarantee that the value does not go out of range.
Parameters:
  otherTime - The double datetime
Parameters:
  timeScale - The time scale to convert from The datetime converted to the universal time scale



bigDecimalFrom
public static BigDecimal bigDecimalFrom(long otherTime, int timeScale)(Code)
Convert a long datetime from the given time scale to the universal time scale. All calculations are done using BigDecimal to guarantee that the value does not go out of range.
Parameters:
  otherTime - The long datetime
Parameters:
  timeScale - The time scale to convert from The datetime converted to the universal time scale



bigDecimalFrom
public static BigDecimal bigDecimalFrom(BigDecimal otherTime, int timeScale)(Code)
Convert a BigDecimal datetime from the given time scale to the universal time scale. All calculations are done using BigDecimal to guarantee that the value does not go out of range.
Parameters:
  otherTime - The BigDecimal datetime
Parameters:
  timeScale - The time scale to convert from The datetime converted to the universal time scale



from
public static long from(long otherTime, int timeScale)(Code)
Convert a long datetime from the given time scale to the universal time scale.
Parameters:
  otherTime - The long datetime
Parameters:
  timeScale - The time scale to convert from The datetime converted to the universal time scale



getTimeScaleValue
public static long getTimeScaleValue(int scale, int value)(Code)
Get a value associated with a particular time scale.
Parameters:
  scale - - the time scale
Parameters:
  value - - a constant representing the value to get - the value.



toBigDecimal
public static BigDecimal toBigDecimal(long universalTime, int timeScale)(Code)
Convert a datetime from the universal time scale to a BigDecimal in the given time scale.
Parameters:
  universalTime - The datetime in the universal time scale
Parameters:
  timeScale - The time scale to convert to The datetime converted to the given time scale



toBigDecimal
public static BigDecimal toBigDecimal(BigDecimal universalTime, int timeScale)(Code)
Convert a datetime from the universal time scale to a BigDecimal in the given time scale.
Parameters:
  universalTime - The datetime in the universal time scale
Parameters:
  timeScale - The time scale to convert to The datetime converted to the given time scale



toBigDecimalTrunc
public static BigDecimal toBigDecimalTrunc(BigDecimal universalTime, int timeScale)(Code)
Convert a time in the Universal Time Scale into another time scale. The division used to do the conversion rounds down. NOTE: This is an internal routine used by the tool that generates the to and from limits. Use it at your own risk.
Parameters:
  universalTime - the time in the Universal Time scale
Parameters:
  timeScale - the time scale to convert to the time in the given time scale



toLong
public static long toLong(long universalTime, int timeScale)(Code)
Convert a datetime from the universal time scale stored as a BigDecimal to a long in the given time scale. Since this calculation requires a divide, we must round. The straight forward way to round by adding half of the divisor will push the sum out of range for values within have the divisor of the limits of the precision of a long. To get around this, we do the rounding like this:

(universalTime - units + units/2) / units + 1

(i.e. we subtract units first to guarantee that we'll still be in range when we add units/2. We then need to add one to the quotent to make up for the extra subtraction. This simplifies to:

(universalTime - units/2) / units - 1

For negative values to round away from zero, we need to flip the signs:

(universalTime + units/2) / units + 1

Since we also need to subtract the epochOffset, we fold the +/- 1 into the offset value. (i.e. epochOffsetP1, epochOffsetM1.)
Parameters:
  universalTime - The datetime in the universal time scale
Parameters:
  timeScale - The time scale to convert to The datetime converted to the given time scale




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.