Java Doc for Instant.java in  » Development » Joda-Time » org » joda » time » 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 » Development » Joda Time » org.joda.time 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.joda.time.base.AbstractInstant
      org.joda.time.Instant

Instant
final public class Instant extends AbstractInstant implements ReadableInstant,Serializable(Code)
Instant is the standard implementation of a fully immutable instant in time.

Instant is an implementation of ReadableInstant . As with all instants, it represents an exact point on the time-line, but limited to the precision of milliseconds. An Instant should be used to represent a point in time irrespective of any other factor, such as chronology or time zone.

Internally, the class holds one piece of data, the instant as milliseconds from the Java epoch of 1970-01-01T00:00:00Z.

For example, an Instant can be used to compare two DateTime objects irrespective of chronology or time zone.

 boolean sameInstant = dt1.toInstant().equals(dt2.toInstant());
 
Note that the following code will also perform the same check:
 boolean sameInstant = dt1.isEqual(dt2);
 

Instant is thread-safe and immutable.
author:
   Stephen Colebourne
since:
   1.0




Constructor Summary
public  Instant()
     Constructs an instance set to the current system millisecond time.
public  Instant(long instant)
     Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z.
public  Instant(Object instant)
     Constructs an instance from an Object that represents a datetime.

Method Summary
public  ChronologygetChronology()
     Gets the chronology of the instant, which is ISO in the UTC zone.
public  longgetMillis()
     Gets the milliseconds of the instant.
public  Instantminus(long duration)
     Gets a copy of this instant with the specified duration taken away.
public  Instantminus(ReadableDuration duration)
     Gets a copy of this instant with the specified duration taken away.
public  Instantplus(long duration)
     Gets a copy of this instant with the specified duration added.
public  Instantplus(ReadableDuration duration)
     Gets a copy of this instant with the specified duration added.
public  DateTimetoDateTime()
     Get this object as a DateTime using ISOChronology in the default zone.

This method returns a DateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone.

public  DateTimetoDateTimeISO()
     Get this object as a DateTime using ISOChronology in the default zone. This method is identical to toDateTime().

This method returns a DateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone.

public  InstanttoInstant()
     Get this object as an Instant by returning this.
public  MutableDateTimetoMutableDateTime()
     Get this object as a MutableDateTime using ISOChronology in the default zone.

This method returns a MutableDateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone.

public  MutableDateTimetoMutableDateTimeISO()
     Get this object as a MutableDateTime using ISOChronology in the default zone. This method is identical to toMutableDateTime().

This method returns a MutableDateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone.

public  InstantwithDurationAdded(long durationToAdd, int scalar)
     Gets a copy of this instant with the specified duration added.
public  InstantwithDurationAdded(ReadableDuration durationToAdd, int scalar)
     Gets a copy of this instant with the specified duration added.
public  InstantwithMillis(long newMillis)
     Gets a copy of this instant with different millis.


Constructor Detail
Instant
public Instant()(Code)
Constructs an instance set to the current system millisecond time.



Instant
public Instant(long instant)(Code)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z.
Parameters:
  instant - the milliseconds from 1970-01-01T00:00:00Z



Instant
public Instant(Object instant)(Code)
Constructs an instance from an Object that represents a datetime.

The recognised object types are defined in ConverterManager and include String, Calendar and Date.
Parameters:
  instant - the datetime object, null means now
throws:
  IllegalArgumentException - if the instant is invalid





Method Detail
getChronology
public Chronology getChronology()(Code)
Gets the chronology of the instant, which is ISO in the UTC zone.

This method returns ISOChronology.getInstanceUTC which corresponds to the definition of the Java epoch 1970-01-01T00:00:00Z. ISO in the UTC zone




getMillis
public long getMillis()(Code)
Gets the milliseconds of the instant. the number of milliseconds since 1970-01-01T00:00:00Z



minus
public Instant minus(long duration)(Code)
Gets a copy of this instant with the specified duration taken away.

If the amount is zero or null, then this is returned.
Parameters:
  duration - the duration to reduce this instant by a copy of this instant with the duration taken away
throws:
  ArithmeticException - if the new instant exceeds the capacity of a long




minus
public Instant minus(ReadableDuration duration)(Code)
Gets a copy of this instant with the specified duration taken away.

If the amount is zero or null, then this is returned.
Parameters:
  duration - the duration to reduce this instant by a copy of this instant with the duration taken away
throws:
  ArithmeticException - if the new instant exceeds the capacity of a long




plus
public Instant plus(long duration)(Code)
Gets a copy of this instant with the specified duration added.

If the amount is zero or null, then this is returned.
Parameters:
  duration - the duration to add to this one a copy of this instant with the duration added
throws:
  ArithmeticException - if the new instant exceeds the capacity of a long




plus
public Instant plus(ReadableDuration duration)(Code)
Gets a copy of this instant with the specified duration added.

If the amount is zero or null, then this is returned.
Parameters:
  duration - the duration to add to this one, null means zero a copy of this instant with the duration added
throws:
  ArithmeticException - if the new instant exceeds the capacity of a long




toDateTime
public DateTime toDateTime()(Code)
Get this object as a DateTime using ISOChronology in the default zone.

This method returns a DateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone. The difference is because Instant really represents a time without a zone, thus calling this method we really have no zone to 'retain' and hence expect to switch to the default zone.

This method definition preserves compatability with earlier versions of Joda-Time. a DateTime using the same millis




toDateTimeISO
public DateTime toDateTimeISO()(Code)
Get this object as a DateTime using ISOChronology in the default zone. This method is identical to toDateTime().

This method returns a DateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone. The difference is because Instant really represents a time without a zone, thus calling this method we really have no zone to 'retain' and hence expect to switch to the default zone.

This method definition preserves compatability with earlier versions of Joda-Time. a DateTime using the same millis with ISOChronology




toInstant
public Instant toInstant()(Code)
Get this object as an Instant by returning this. this



toMutableDateTime
public MutableDateTime toMutableDateTime()(Code)
Get this object as a MutableDateTime using ISOChronology in the default zone.

This method returns a MutableDateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone. The difference is because Instant really represents a time without a zone, thus calling this method we really have no zone to 'retain' and hence expect to switch to the default zone.

This method definition preserves compatability with earlier versions of Joda-Time. a MutableDateTime using the same millis




toMutableDateTimeISO
public MutableDateTime toMutableDateTimeISO()(Code)
Get this object as a MutableDateTime using ISOChronology in the default zone. This method is identical to toMutableDateTime().

This method returns a MutableDateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone. The difference is because Instant really represents a time without a zone, thus calling this method we really have no zone to 'retain' and hence expect to switch to the default zone.

This method definition preserves compatability with earlier versions of Joda-Time. a MutableDateTime using the same millis with ISOChronology




withDurationAdded
public Instant withDurationAdded(long durationToAdd, int scalar)(Code)
Gets a copy of this instant with the specified duration added.

If the addition is zero, then this is returned.
Parameters:
  durationToAdd - the duration to add to this one
Parameters:
  scalar - the amount of times to add, such as -1 to subtract once a copy of this instant with the duration added
throws:
  ArithmeticException - if the new instant exceeds the capacity of a long




withDurationAdded
public Instant withDurationAdded(ReadableDuration durationToAdd, int scalar)(Code)
Gets a copy of this instant with the specified duration added.

If the addition is zero, then this is returned.
Parameters:
  durationToAdd - the duration to add to this one, null means zero
Parameters:
  scalar - the amount of times to add, such as -1 to subtract once a copy of this instant with the duration added
throws:
  ArithmeticException - if the new instant exceeds the capacity of a long




withMillis
public Instant withMillis(long newMillis)(Code)
Gets a copy of this instant with different millis.

The returned object will be either be a new Instant or this.
Parameters:
  newMillis - the new millis, from 1970-01-01T00:00:00Z a copy of this instant with different millis




Methods inherited from org.joda.time.base.AbstractInstant
public int compareTo(Object instant)(Code)(Java Doc)
public boolean equals(Object readableInstant)(Code)(Java Doc)
public int get(DateTimeFieldType type)(Code)(Java Doc)
public int get(DateTimeField field)(Code)(Java Doc)
public DateTimeZone getZone()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public boolean isAfter(long instant)(Code)(Java Doc)
public boolean isAfter(ReadableInstant instant)(Code)(Java Doc)
public boolean isAfterNow()(Code)(Java Doc)
public boolean isBefore(long instant)(Code)(Java Doc)
public boolean isBefore(ReadableInstant instant)(Code)(Java Doc)
public boolean isBeforeNow()(Code)(Java Doc)
public boolean isEqual(long instant)(Code)(Java Doc)
public boolean isEqual(ReadableInstant instant)(Code)(Java Doc)
public boolean isEqualNow()(Code)(Java Doc)
public boolean isSupported(DateTimeFieldType type)(Code)(Java Doc)
public Date toDate()(Code)(Java Doc)
public DateTime toDateTime()(Code)(Java Doc)
public DateTime toDateTime(DateTimeZone zone)(Code)(Java Doc)
public DateTime toDateTime(Chronology chronology)(Code)(Java Doc)
public DateTime toDateTimeISO()(Code)(Java Doc)
public Instant toInstant()(Code)(Java Doc)
public MutableDateTime toMutableDateTime()(Code)(Java Doc)
public MutableDateTime toMutableDateTime(DateTimeZone zone)(Code)(Java Doc)
public MutableDateTime toMutableDateTime(Chronology chronology)(Code)(Java Doc)
public MutableDateTime toMutableDateTimeISO()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public String toString(DateTimeFormatter formatter)(Code)(Java Doc)

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.