Java Doc for Partial.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.AbstractPartial
      org.joda.time.Partial

Partial
final public class Partial extends AbstractPartial implements ReadablePartial,Serializable(Code)
Partial is an immutable partial datetime supporting any set of datetime fields.

A Partial instance can be used to hold any combination of fields. The instance does not contain a time zone, so any datetime is local.

A Partial can be matched against an instant using Partial.isMatch(ReadableInstant) . This method compares each field on this partial with those of the instant and determines if the partial matches the instant. Given this definition, an empty Partial instance represents any datetime and always matches.

Calculations on Partial are performed using a Chronology . This chronology is set to be in the UTC time zone for all calculations.

Each individual field can be queried in two ways:

  • get(DateTimeFieldType.monthOfYear())
  • property(DateTimeFieldType.monthOfYear()).get()
The second technique also provides access to other useful methods on the field:
  • numeric value - monthOfYear().get()
  • text value - monthOfYear().getAsText()
  • short text value - monthOfYear().getAsShortText()
  • maximum/minimum values - monthOfYear().getMaximumValue()
  • add/subtract - monthOfYear().addToCopy()
  • set - monthOfYear().setCopy()

Partial is thread-safe and immutable, provided that the Chronology is as well. All standard Chronology classes supplied are thread-safe and immutable.
author:
   Stephen Colebourne
since:
   1.1


Inner Class :public static class Property extends AbstractPartialFieldProperty implements Serializable


Constructor Summary
public  Partial()
     Constructs a Partial with no fields or values, which can be considered to represent any date.
public  Partial(Chronology chrono)
     Constructs a Partial with no fields or values, which can be considered to represent any date.
public  Partial(DateTimeFieldType type, int value)
     Constructs a Partial with the specified field and value.
public  Partial(DateTimeFieldType type, int value, Chronology chronology)
     Constructs a Partial with the specified field and value.
public  Partial(DateTimeFieldType[] types, int[] values)
     Constructs a Partial with the specified fields and values.
public  Partial(DateTimeFieldType[] types, int[] values, Chronology chronology)
     Constructs a Partial with the specified fields and values.
public  Partial(ReadablePartial partial)
     Constructs a Partial by copying all the fields and types from another partial.
 Partial(Partial partial, int[] values)
     Constructs a Partial with the specified values.
 Partial(Chronology chronology, DateTimeFieldType[] types, int[] values)
     Constructs a Partial with the specified chronology, fields and values.

Method Summary
public  ChronologygetChronology()
     Gets the chronology of the partial which is never null.
protected  DateTimeFieldgetField(int index, Chronology chrono)
     Gets the field for a specific index in the chronology specified.
public  DateTimeFieldTypegetFieldType(int index)
     Gets the field type at the specified index.
public  DateTimeFieldType[]getFieldTypes()
     Gets an array of the field type of each of the fields that this partial supports.
public  DateTimeFormattergetFormatter()
     Gets a formatter suitable for the fields in this partial.

If there is no appropriate ISO format, null is returned. This method may return a formatter that does not display all the fields of the partial.

public  intgetValue(int index)
     Gets the value of the field at the specifed index.
public  int[]getValues()
     Gets an array of the value of each of the fields that this partial supports.
public  booleanisMatch(ReadableInstant instant)
     Does this partial match the specified instant.
public  booleanisMatch(ReadablePartial partial)
     Does this partial match the specified partial.
public  Partialminus(ReadablePeriod period)
     Gets a copy of this instance with the specified period take away.
public  Partialplus(ReadablePeriod period)
     Gets a copy of this instance with the specified period added.
public  Propertyproperty(DateTimeFieldType type)
     Gets the property object for the specified type, which contains many useful methods for getting and manipulating the partial.
public  intsize()
     Gets the number of fields in this partial.
public  StringtoString()
     Output the date in an appropriate ISO8601 format.
public  StringtoString(String pattern)
     Output the date using the specified format pattern.
public  StringtoString(String pattern, Locale locale)
     Output the date using the specified format pattern.
public  StringtoStringList()
     Gets a string version of the partial that lists all the fields.

This method exists to provide a better debugging toString than the standard toString.

public  Partialwith(DateTimeFieldType fieldType, int value)
     Gets a copy of this date with the specified field set to a new value.
public  PartialwithChronologyRetainFields(Chronology newChronology)
     Creates a new Partial instance with the specified chronology.
public  PartialwithField(DateTimeFieldType fieldType, int value)
     Gets a copy of this Partial with the specified field set to a new value.
public  PartialwithFieldAddWrapped(DurationFieldType fieldType, int amount)
     Gets a copy of this Partial with the value of the specified field increased. If this partial does not support the field, an exception is thrown.

If the addition is zero, then this is returned. The addition will overflow into larger fields (eg.

public  PartialwithFieldAdded(DurationFieldType fieldType, int amount)
     Gets a copy of this Partial with the value of the specified field increased. If this partial does not support the field, an exception is thrown.

If the addition is zero, then this is returned. The addition will overflow into larger fields (eg.

public  PartialwithPeriodAdded(ReadablePeriod period, int scalar)
     Gets a copy of this Partial with the specified period added.

If the addition is zero, then this is returned. Fields in the period that aren't present in the partial are ignored.

This method is typically used to add multiple copies of complex period instances.

public  Partialwithout(DateTimeFieldType fieldType)
     Gets a copy of this date with the specified field removed.


Constructor Detail
Partial
public Partial()(Code)
Constructs a Partial with no fields or values, which can be considered to represent any date.

This is most useful when constructing partials, for example:

 Partial p = new Partial()
 .with(DateTimeFieldType.dayOfWeek(), 5)
 .with(DateTimeFieldType.hourOfDay(), 12)
 .with(DateTimeFieldType.minuteOfHour(), 20);
 
Note that, although this is a clean way to write code, it is fairly inefficient internally.

The constructor uses the default ISO chronology.




Partial
public Partial(Chronology chrono)(Code)
Constructs a Partial with no fields or values, which can be considered to represent any date.

This is most useful when constructing partials, for example:

 Partial p = new Partial(chrono)
 .with(DateTimeFieldType.dayOfWeek(), 5)
 .with(DateTimeFieldType.hourOfDay(), 12)
 .with(DateTimeFieldType.minuteOfHour(), 20);
 
Note that, although this is a clean way to write code, it is fairly inefficient internally.
Parameters:
  chrono - the chronology, null means ISO



Partial
public Partial(DateTimeFieldType type, int value)(Code)
Constructs a Partial with the specified field and value.

The constructor uses the default ISO chronology.
Parameters:
  type - the single type to create the partial from, not null
Parameters:
  value - the value to store
throws:
  IllegalArgumentException - if the type or value is invalid




Partial
public Partial(DateTimeFieldType type, int value, Chronology chronology)(Code)
Constructs a Partial with the specified field and value.

The constructor uses the specified chronology.
Parameters:
  type - the single type to create the partial from, not null
Parameters:
  value - the value to store
Parameters:
  chronology - the chronology, null means ISO
throws:
  IllegalArgumentException - if the type or value is invalid




Partial
public Partial(DateTimeFieldType[] types, int[] values)(Code)
Constructs a Partial with the specified fields and values. The fields must be specified in the order largest to smallest.

The constructor uses the specified chronology.
Parameters:
  types - the types to create the partial from, not null
Parameters:
  values - the values to store, not null
throws:
  IllegalArgumentException - if the types or values are invalid




Partial
public Partial(DateTimeFieldType[] types, int[] values, Chronology chronology)(Code)
Constructs a Partial with the specified fields and values. The fields must be specified in the order largest to smallest.

The constructor uses the specified chronology.
Parameters:
  types - the types to create the partial from, not null
Parameters:
  values - the values to store, not null
Parameters:
  chronology - the chronology, null means ISO
throws:
  IllegalArgumentException - if the types or values are invalid




Partial
public Partial(ReadablePartial partial)(Code)
Constructs a Partial by copying all the fields and types from another partial.

This is most useful when copying from a YearMonthDay or TimeOfDay.




Partial
Partial(Partial partial, int[] values)(Code)
Constructs a Partial with the specified values. This constructor assigns and performs no validation.
Parameters:
  partial - the partial to copy
Parameters:
  values - the values to store
throws:
  IllegalArgumentException - if the types or values are invalid



Partial
Partial(Chronology chronology, DateTimeFieldType[] types, int[] values)(Code)
Constructs a Partial with the specified chronology, fields and values. This constructor assigns and performs no validation.
Parameters:
  chronology - the chronology
Parameters:
  types - the types to create the partial from
Parameters:
  values - the values to store
throws:
  IllegalArgumentException - if the types or values are invalid




Method Detail
getChronology
public Chronology getChronology()(Code)
Gets the chronology of the partial which is never null.

The Chronology is the calculation engine behind the partial and provides conversion and validation of the fields in a particular calendar system. the chronology, never null




getField
protected DateTimeField getField(int index, Chronology chrono)(Code)
Gets the field for a specific index in the chronology specified.
Parameters:
  index - the index to retrieve
Parameters:
  chrono - the chronology to use the field
throws:
  IndexOutOfBoundsException - if the index is invalid



getFieldType
public DateTimeFieldType getFieldType(int index)(Code)
Gets the field type at the specified index.
Parameters:
  index - the index to retrieve the field at the specified index
throws:
  IndexOutOfBoundsException - if the index is invalid



getFieldTypes
public DateTimeFieldType[] getFieldTypes()(Code)
Gets an array of the field type of each of the fields that this partial supports.

The fields are returned largest to smallest. the array of field types (cloned), largest to smallest




getFormatter
public DateTimeFormatter getFormatter()(Code)
Gets a formatter suitable for the fields in this partial.

If there is no appropriate ISO format, null is returned. This method may return a formatter that does not display all the fields of the partial. This might occur when you have overlapping fields, such as dayOfWeek and dayOfMonth. a formatter suitable for the fields in this partial, nullif none is suitable




getValue
public int getValue(int index)(Code)
Gets the value of the field at the specifed index.
Parameters:
  index - the index the value
throws:
  IndexOutOfBoundsException - if the index is invalid



getValues
public int[] getValues()(Code)
Gets an array of the value of each of the fields that this partial supports.

The fields are returned largest to smallest. Each value corresponds to the same array index as getFieldTypes() the current values of each field (cloned), largest to smallest




isMatch
public boolean isMatch(ReadableInstant instant)(Code)
Does this partial match the specified instant.

A match occurs when all the fields of this partial are the same as the corresponding fields on the specified instant.
Parameters:
  instant - an instant to check against, null means now in default zone true if this partial matches the specified instant




isMatch
public boolean isMatch(ReadablePartial partial)(Code)
Does this partial match the specified partial.

A match occurs when all the fields of this partial are the same as the corresponding fields on the specified partial.
Parameters:
  partial - a partial to check against, must not be null true if this partial matches the specified partial
throws:
  IllegalArgumentException - if the partial is null
throws:
  IllegalArgumentException - if the fields of the two partials do not match
since:
   1.5




minus
public Partial minus(ReadablePeriod period)(Code)
Gets a copy of this instance with the specified period take away.

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




plus
public Partial plus(ReadablePeriod period)(Code)
Gets a copy of this instance with the specified period added.

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




property
public Property property(DateTimeFieldType type)(Code)
Gets the property object for the specified type, which contains many useful methods for getting and manipulating the partial.

See also ReadablePartial.get(DateTimeFieldType) .
Parameters:
  type - the field type to get the property for, not null the property object
throws:
  IllegalArgumentException - if the field is null or unsupported




size
public int size()(Code)
Gets the number of fields in this partial. the field count



toString
public String toString()(Code)
Output the date in an appropriate ISO8601 format.

This method will output the partial in one of two ways. If Partial.getFormatter()

If there is no appropriate ISO format a dump of the fields is output via Partial.toStringList() . ISO8601 formatted string




toString
public String toString(String pattern)(Code)
Output the date using the specified format pattern. Unsupported fields will appear as special unicode characters.
Parameters:
  pattern - the pattern specification, null means use toString
See Also:   org.joda.time.format.DateTimeFormat



toString
public String toString(String pattern, Locale locale)(Code)
Output the date using the specified format pattern. Unsupported fields will appear as special unicode characters.
Parameters:
  pattern - the pattern specification, null means use toString
Parameters:
  locale - Locale to use, null means default
See Also:   org.joda.time.format.DateTimeFormat



toStringList
public String toStringList()(Code)
Gets a string version of the partial that lists all the fields.

This method exists to provide a better debugging toString than the standard toString. This method lists all the fields and their values in a style similar to the collections framework. a toString format that lists all the fields




with
public Partial with(DateTimeFieldType fieldType, int value)(Code)
Gets a copy of this date with the specified field set to a new value.

If this partial did not previously support the field, the new one will. Contrast this behaviour with Partial.withField(DateTimeFieldType,int) .

For example, if the field type is dayOfMonth then the day would be changed/added in the returned instance.
Parameters:
  fieldType - the field type to set, not null
Parameters:
  value - the value to set a copy of this instance with the field set
throws:
  IllegalArgumentException - if the value is null or invalid




withChronologyRetainFields
public Partial withChronologyRetainFields(Chronology newChronology)(Code)
Creates a new Partial instance with the specified chronology. This instance is immutable and unaffected by this method call.

This method retains the values of the fields, thus the result will typically refer to a different instant.

The time zone of the specified chronology is ignored, as Partial operates without a time zone.
Parameters:
  newChronology - the new chronology, null means ISO a copy of this datetime with a different chronology
throws:
  IllegalArgumentException - if the values are invalid for the new chronology




withField
public Partial withField(DateTimeFieldType fieldType, int value)(Code)
Gets a copy of this Partial with the specified field set to a new value.

If this partial does not support the field, an exception is thrown. Contrast this behaviour with Partial.with(DateTimeFieldType,int) .

For example, if the field type is dayOfMonth then the day would be changed in the returned instance if supported.
Parameters:
  fieldType - the field type to set, not null
Parameters:
  value - the value to set a copy of this instance with the field set
throws:
  IllegalArgumentException - if the value is null or invalid




withFieldAddWrapped
public Partial withFieldAddWrapped(DurationFieldType fieldType, int amount)(Code)
Gets a copy of this Partial with the value of the specified field increased. If this partial does not support the field, an exception is thrown.

If the addition is zero, then this is returned. The addition will overflow into larger fields (eg. minute to hour). If the maximum is reached, the addition will wra.
Parameters:
  fieldType - the field type to add to, not null
Parameters:
  amount - the amount to add a copy of this instance with the field updated
throws:
  IllegalArgumentException - if the value is null or invalid
throws:
  ArithmeticException - if the new datetime exceeds the capacity




withFieldAdded
public Partial withFieldAdded(DurationFieldType fieldType, int amount)(Code)
Gets a copy of this Partial with the value of the specified field increased. If this partial does not support the field, an exception is thrown.

If the addition is zero, then this is returned. The addition will overflow into larger fields (eg. minute to hour). However, it will not wrap around if the top maximum is reached.
Parameters:
  fieldType - the field type to add to, not null
Parameters:
  amount - the amount to add a copy of this instance with the field updated
throws:
  IllegalArgumentException - if the value is null or invalid
throws:
  ArithmeticException - if the new datetime exceeds the capacity




withPeriodAdded
public Partial withPeriodAdded(ReadablePeriod period, int scalar)(Code)
Gets a copy of this Partial with the specified period added.

If the addition is zero, then this is returned. Fields in the period that aren't present in the partial are ignored.

This method is typically used to add multiple copies of complex period instances. Adding one field is best achieved using the method Partial.withFieldAdded(DurationFieldType,int) .
Parameters:
  period - the period 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 instance with the period added
throws:
  ArithmeticException - if the new datetime exceeds the capacity




without
public Partial without(DateTimeFieldType fieldType)(Code)
Gets a copy of this date with the specified field removed.

If this partial did not previously support the field, no error occurs.
Parameters:
  fieldType - the field type to remove, may be null a copy of this instance with the field removed




Methods inherited from org.joda.time.base.AbstractPartial
public int compareTo(Object partial)(Code)(Java Doc)
public boolean equals(Object partial)(Code)(Java Doc)
public int get(DateTimeFieldType type)(Code)(Java Doc)
abstract protected DateTimeField getField(int index, Chronology chrono)(Code)(Java Doc)
public DateTimeField getField(int index)(Code)(Java Doc)
public DateTimeFieldType getFieldType(int index)(Code)(Java Doc)
public DateTimeFieldType[] getFieldTypes()(Code)(Java Doc)
public DateTimeField[] getFields()(Code)(Java Doc)
public int[] getValues()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public int indexOf(DateTimeFieldType type)(Code)(Java Doc)
protected int indexOf(DurationFieldType type)(Code)(Java Doc)
protected int indexOfSupported(DateTimeFieldType type)(Code)(Java Doc)
protected int indexOfSupported(DurationFieldType type)(Code)(Java Doc)
public boolean isAfter(ReadablePartial partial)(Code)(Java Doc)
public boolean isBefore(ReadablePartial partial)(Code)(Java Doc)
public boolean isEqual(ReadablePartial partial)(Code)(Java Doc)
public boolean isSupported(DateTimeFieldType type)(Code)(Java Doc)
public DateTime toDateTime(ReadableInstant baseInstant)(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.