Java Doc for LocalDate.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) 


org.joda.time.base.BaseLocal
   org.joda.time.LocalDate

LocalDate
final public class LocalDate extends BaseLocal implements ReadablePartial,Serializable(Code)
LocalDate is an immutable datetime class representing a date without a time zone.

LocalDate implements the ReadablePartial interface. To do this, the interface methods focus on the key fields - Year, MonthOfYear and DayOfMonth. However, all date fields may in fact be queried.

LocalDate differs from DateMidnight in that this class does not have a time zone and does not represent a single instant in time.

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

Each individual field can be queried in two ways:

  • getMonthOfYear()
  • monthOfYear().get()
The second technique also provides access to other useful methods on the field:
  • numeric value
  • text value
  • short text value
  • maximum/minimum values
  • add/subtract
  • set
  • rounding

LocalDate 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.3


Inner Class :final public static class Property extends AbstractReadableInstantFieldProperty


Constructor Summary
public  LocalDate()
     Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.
public  LocalDate(DateTimeZone zone)
     Constructs an instance set to the current local time evaluated using ISO chronology in the specified zone.
public  LocalDate(Chronology chronology)
     Constructs an instance set to the current local time evaluated using specified chronology.
public  LocalDate(long instant)
     Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the default zone.
public  LocalDate(long instant, DateTimeZone zone)
     Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the specified zone.
public  LocalDate(long instant, Chronology chronology)
     Constructs an instance set to the local time defined by the specified instant evaluated using the specified chronology.
public  LocalDate(Object instant)
     Constructs an instance from an Object that represents a datetime.
public  LocalDate(Object instant, DateTimeZone zone)
     Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.
public  LocalDate(Object instant, Chronology chronology)
     Constructs an instance from an Object that represents a datetime, using the specified chronology.
public  LocalDate(int year, int monthOfYear, int dayOfMonth)
     Constructs an instance set to the specified date and time using ISOChronology.
public  LocalDate(int year, int monthOfYear, int dayOfMonth, Chronology chronology)
     Constructs an instance set to the specified date and time using the specified chronology, whose zone is ignored.

Method Summary
public  PropertycenturyOfEra()
     Get the century of era property which provides access to advanced functionality.
public  intcompareTo(Object partial)
     Compares this partial with another returning an integer indicating the order.
public  PropertydayOfMonth()
     Get the day of month property which provides access to advanced functionality.
public  PropertydayOfWeek()
     Get the day of week property which provides access to advanced functionality.
public  PropertydayOfYear()
     Get the day of year property which provides access to advanced functionality.
public  booleanequals(Object partial)
     Compares this ReadablePartial with another returning true if the chronology, field types and values are equal.
public  Propertyera()
     Get the era property which provides access to advanced functionality.
public static  LocalDatefromCalendarFields(Calendar calendar)
     Constructs a LocalDate from a java.util.Calendar using exactly the same field values avoiding any time zone effects.

Each field is queried from the Calendar and assigned to the LocalDate. This is useful if you have been using the Calendar as a local date, ignoing the zone.

This factory method ignores the type of the calendar and always creates a LocalDate with ISO chronology.

public static  LocalDatefromDateFields(Date date)
     Constructs a LocalDate from a java.util.Date using exactly the same field values avoiding any time zone effects.
public  intget(DateTimeFieldType fieldType)
     Get the value of one of the fields of a datetime.
public  intgetCenturyOfEra()
     Get the year of era field value.
public  ChronologygetChronology()
     Gets the chronology of the date.
public  intgetDayOfMonth()
     Get the day of month field value.
public  intgetDayOfWeek()
     Get the day of week field value.
public  intgetDayOfYear()
     Get the day of year field value.
public  intgetEra()
     Get the era field value.
protected  DateTimeFieldgetField(int index, Chronology chrono)
     Gets the field for a specific index in the chronology specified.
protected  longgetLocalMillis()
     Gets the local milliseconds from the Java epoch of 1970-01-01T00:00:00 (not fixed to any specific time zone).
public  intgetMonthOfYear()
     Get the month of year field value.
public  intgetValue(int index)
     Gets the value of the field at the specifed index.

This method is required to support the ReadablePartial interface.

public  intgetWeekOfWeekyear()
     Get the week of weekyear field value.
public  intgetWeekyear()
     Get the weekyear field value.

The weekyear is the year that matches with the weekOfWeekyear field. In the standard ISO8601 week algorithm, the first week of the year is that in which at least 4 days are in the year.

public  intgetYear()
     Get the year field value.
public  intgetYearOfCentury()
     Get the year of century field value.
public  intgetYearOfEra()
     Get the year of era field value.
public  booleanisSupported(DateTimeFieldType type)
     Checks if the field type specified is supported by this local date and chronology.
public  booleanisSupported(DurationFieldType type)
     Checks if the duration type specified is supported by this local date and chronology.
public  LocalDateminus(ReadablePeriod period)
     Returns a copy of this date with the specified period taken away.
public  LocalDateminusDays(int days)
     Returns a copy of this date minus the specified number of days.
public  LocalDateminusMonths(int months)
     Returns a copy of this date minus the specified number of months.
public  LocalDateminusWeeks(int weeks)
     Returns a copy of this date minus the specified number of weeks.
public  LocalDateminusYears(int years)
     Returns a copy of this date minus the specified number of years.
public  PropertymonthOfYear()
     Get the month of year property which provides access to advanced functionality.
public  LocalDateplus(ReadablePeriod period)
     Returns a copy of this date with the specified period added.
public  LocalDateplusDays(int days)
     Returns a copy of this date plus the specified number of days.
public  LocalDateplusMonths(int months)
     Returns a copy of this date plus the specified number of months.
public  LocalDateplusWeeks(int weeks)
     Returns a copy of this date plus the specified number of weeks.
public  LocalDateplusYears(int years)
     Returns a copy of this date plus the specified number of years.
public  Propertyproperty(DateTimeFieldType fieldType)
     Gets the property object for the specified type, which contains many useful methods.
public  intsize()
     Gets the number of fields in this partial, which is three.
public  DateMidnighttoDateMidnight()
     Converts this LocalDate to a DateMidnight in the default time zone.

As from v1.5, you are recommended to avoid DateMidnight and use LocalDate.toDateTimeAtStartOfDay() instead because of the exception detailed below.

This method will throw an exception if the default time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date.

public  DateMidnighttoDateMidnight(DateTimeZone zone)
     Converts this LocalDate to a DateMidnight.

As from v1.5, you are recommended to avoid DateMidnight and use LocalDate.toDateTimeAtStartOfDay() instead because of the exception detailed below.

This method will throw an exception if the time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date.

public  DateTimetoDateTime(LocalTime time)
     Converts this object to a DateTime using a LocalTime to fill in the missing fields and using the default time zone.

The resulting chronology is determined by the chronology of this LocalDate.

public  DateTimetoDateTime(LocalTime time, DateTimeZone zone)
     Converts this object to a DateTime using a LocalTime to fill in the missing fields.

The resulting chronology is determined by the chronology of this LocalDate plus the time zone.

public  DateTimetoDateTimeAtCurrentTime()
     Converts this LocalDate to a full datetime using the default time zone setting the date fields from this instance and the time fields from the current time.
public  DateTimetoDateTimeAtCurrentTime(DateTimeZone zone)
     Converts this LocalDate to a full datetime using the specified time zone setting the date fields from this instance and the time fields from the current time.
public  DateTimetoDateTimeAtMidnight()
     Converts this LocalDate to a full datetime at midnight using the default time zone.

This method will throw an exception if the default time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date.

public  DateTimetoDateTimeAtMidnight(DateTimeZone zone)
     Converts this LocalDate to a full datetime at midnight using the specified time zone.

This method will throw an exception if the time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date.

public  DateTimetoDateTimeAtStartOfDay()
     Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.

The time will normally be midnight, as that is the earliest time on any given day.

public  DateTimetoDateTimeAtStartOfDay(DateTimeZone zone)
     Converts this LocalDate to a full datetime at the earliest valid time for the date using the specified time zone.

The time will normally be midnight, as that is the earliest time on any given day.

public  IntervaltoInterval()
     Converts this object to an Interval representing the whole day in the default time zone.
public  IntervaltoInterval(DateTimeZone zone)
     Converts this object to an Interval representing the whole day.
public  LocalDateTimetoLocalDateTime(LocalTime time)
     Converts this object to a LocalDateTime using a LocalTime to fill in the missing fields.

The resulting chronology is determined by the chronology of this LocalDate.

public  StringtoString()
     Output the date time in ISO8601 format (yyyy-MM-dd).
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  PropertyweekOfWeekyear()
     Get the week of a week based year property which provides access to advanced functionality.
public  Propertyweekyear()
     Get the weekyear property which provides access to advanced functionality.
public  LocalDatewithCenturyOfEra(int centuryOfEra)
     Returns a copy of this date with the century of era field updated.
public  LocalDatewithDayOfMonth(int dayOfMonth)
     Returns a copy of this date with the day of month field updated.
public  LocalDatewithDayOfWeek(int dayOfWeek)
     Returns a copy of this date with the day of week field updated.
public  LocalDatewithDayOfYear(int dayOfYear)
     Returns a copy of this date with the day of year field updated.
public  LocalDatewithEra(int era)
     Returns a copy of this date with the era field updated.
public  LocalDatewithField(DateTimeFieldType fieldType, int value)
     Returns a copy of this date with the specified field set to a new value.
public  LocalDatewithFieldAdded(DurationFieldType fieldType, int amount)
     Returns a copy of this date with the value of the specified field increased.
public  LocalDatewithFields(ReadablePartial partial)
     Returns a copy of this date with the partial set of fields replacing those from this instance.
 LocalDatewithLocalMillis(long newMillis)
     Returns a copy of this date with different local millis.
public  LocalDatewithMonthOfYear(int monthOfYear)
     Returns a copy of this date with the month of year field updated.
public  LocalDatewithPeriodAdded(ReadablePeriod period, int scalar)
     Returns a copy of this date with the specified period added.

If the addition is zero, then this is returned.

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

public  LocalDatewithWeekOfWeekyear(int weekOfWeekyear)
     Returns a copy of this date with the week of weekyear field updated.
public  LocalDatewithWeekyear(int weekyear)
     Returns a copy of this date with the weekyear field updated.
public  LocalDatewithYear(int year)
     Returns a copy of this date with the year field updated.
public  LocalDatewithYearOfCentury(int yearOfCentury)
     Returns a copy of this date with the year of century field updated.
public  LocalDatewithYearOfEra(int yearOfEra)
     Returns a copy of this date with the year of era field updated.
public  Propertyyear()
     Get the year property which provides access to advanced functionality.
public  PropertyyearOfCentury()
     Get the year of century property which provides access to advanced functionality.
public  PropertyyearOfEra()
     Get the year of era property which provides access to advanced functionality.


Constructor Detail
LocalDate
public LocalDate()(Code)
Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.

Once the constructor is completed, the zone is no longer used.




LocalDate
public LocalDate(DateTimeZone zone)(Code)
Constructs an instance set to the current local time evaluated using ISO chronology in the specified zone.

If the specified time zone is null, the default zone is used. Once the constructor is completed, the zone is no longer used.
Parameters:
  zone - the time zone, null means default zone




LocalDate
public LocalDate(Chronology chronology)(Code)
Constructs an instance set to the current local time evaluated using specified chronology.

If the chronology is null, ISO chronology in the default time zone is used. Once the constructor is completed, the zone is no longer used.
Parameters:
  chronology - the chronology, null means ISOChronology in default zone




LocalDate
public LocalDate(long instant)(Code)
Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the default zone.

Once the constructor is completed, the zone is no longer used.
Parameters:
  instant - the milliseconds from 1970-01-01T00:00:00Z




LocalDate
public LocalDate(long instant, DateTimeZone zone)(Code)
Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the specified zone.

If the specified time zone is null, the default zone is used. Once the constructor is completed, the zone is no longer used.
Parameters:
  instant - the milliseconds from 1970-01-01T00:00:00Z
Parameters:
  zone - the time zone, null means default zone




LocalDate
public LocalDate(long instant, Chronology chronology)(Code)
Constructs an instance set to the local time defined by the specified instant evaluated using the specified chronology.

If the chronology is null, ISO chronology in the default zone is used. Once the constructor is completed, the zone is no longer used.
Parameters:
  instant - the milliseconds from 1970-01-01T00:00:00Z
Parameters:
  chronology - the chronology, null means ISOChronology in default zone




LocalDate
public LocalDate(Object instant)(Code)
Constructs an instance from an Object that represents a datetime. The time zone will be retrieved from the object if possible, otherwise the default time zone will be used.

If the object contains no chronology, ISOChronology is used. Once the constructor is completed, the zone is no longer used.

The recognised object types are defined in org.joda.time.convert.ConverterManager ConverterManager and include ReadablePartial, ReadableInstant, String, Calendar and Date. The String formats are described by ISODateTimeFormat.localDateParser . The default String converter ignores the zone and only parses the field values.
Parameters:
  instant - the datetime object
throws:
  IllegalArgumentException - if the instant is invalid




LocalDate
public LocalDate(Object instant, DateTimeZone zone)(Code)
Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.

If the object contains no chronology, ISOChronology is used. If the specified time zone is null, the default zone is used. Once the constructor is completed, the zone is no longer used.

The recognised object types are defined in org.joda.time.convert.ConverterManager ConverterManager and include ReadablePartial, ReadableInstant, String, Calendar and Date. The String formats are described by ISODateTimeFormat.localDateParser . The default String converter ignores the zone and only parses the field values.
Parameters:
  instant - the datetime object
Parameters:
  zone - the time zone
throws:
  IllegalArgumentException - if the instant is invalid




LocalDate
public LocalDate(Object instant, Chronology chronology)(Code)
Constructs an instance from an Object that represents a datetime, using the specified chronology.

If the chronology is null, ISO in the default time zone is used. Once the constructor is completed, the zone is no longer used.

The recognised object types are defined in org.joda.time.convert.ConverterManager ConverterManager and include ReadablePartial, ReadableInstant, String, Calendar and Date. The String formats are described by ISODateTimeFormat.localDateParser . The default String converter ignores the zone and only parses the field values.
Parameters:
  instant - the datetime object
Parameters:
  chronology - the chronology
throws:
  IllegalArgumentException - if the instant is invalid




LocalDate
public LocalDate(int year, int monthOfYear, int dayOfMonth)(Code)
Constructs an instance set to the specified date and time using ISOChronology.
Parameters:
  year - the year
Parameters:
  monthOfYear - the month of the year
Parameters:
  dayOfMonth - the day of the month



LocalDate
public LocalDate(int year, int monthOfYear, int dayOfMonth, Chronology chronology)(Code)
Constructs an instance set to the specified date and time using the specified chronology, whose zone is ignored.

If the chronology is null, ISOChronology is used.
Parameters:
  year - the year
Parameters:
  monthOfYear - the month of the year
Parameters:
  dayOfMonth - the day of the month
Parameters:
  chronology - the chronology, null means ISOChronology in default zone





Method Detail
centuryOfEra
public Property centuryOfEra()(Code)
Get the century of era property which provides access to advanced functionality. the year of era property



compareTo
public int compareTo(Object partial)(Code)
Compares this partial with another returning an integer indicating the order.

The fields are compared in order, from largest to smallest. The first field that is non-equal is used to determine the result.

The specified object must be a partial instance whose field types match those of this partial.

NOTE: This implementation violates the Comparable contract. This method will accept any instance of ReadablePartial as input. However, it is possible that some implementations of ReadablePartial exist that do not extend AbstractPartial, and thus will throw a ClassCastException if compared in the opposite direction. The cause of this problem is that ReadablePartial doesn't define the compareTo() method, however we can't change that until v2.0.
Parameters:
  partial - an object to check against negative if this is less, zero if equal, positive if greater
throws:
  ClassCastException - if the partial is the wrong classor if it has field types that don't match
throws:
  NullPointerException - if the partial is null




dayOfMonth
public Property dayOfMonth()(Code)
Get the day of month property which provides access to advanced functionality. the day of month property



dayOfWeek
public Property dayOfWeek()(Code)
Get the day of week property which provides access to advanced functionality. the day of week property



dayOfYear
public Property dayOfYear()(Code)
Get the day of year property which provides access to advanced functionality. the day of year property



equals
public boolean equals(Object partial)(Code)
Compares this ReadablePartial with another returning true if the chronology, field types and values are equal.
Parameters:
  partial - an object to check against true if fields and values are equal



era
public Property era()(Code)
Get the era property which provides access to advanced functionality. the era property



fromCalendarFields
public static LocalDate fromCalendarFields(Calendar calendar)(Code)
Constructs a LocalDate from a java.util.Calendar using exactly the same field values avoiding any time zone effects.

Each field is queried from the Calendar and assigned to the LocalDate. This is useful if you have been using the Calendar as a local date, ignoing the zone.

This factory method ignores the type of the calendar and always creates a LocalDate with ISO chronology. It is expected that you will only pass in instances of GregorianCalendar however this is not validated.
Parameters:
  calendar - the Calendar to extract fields from the created LocalDate
throws:
  IllegalArgumentException - if the calendar is null
throws:
  IllegalArgumentException - if the date is invalid for the ISO chronology




fromDateFields
public static LocalDate fromDateFields(Date date)(Code)
Constructs a LocalDate from a java.util.Date using exactly the same field values avoiding any time zone effects.

Each field is queried from the Date and assigned to the LocalDate. This is useful if you have been using the Date as a local date, ignoing the zone.

This factory method always creates a LocalDate with ISO chronology.
Parameters:
  date - the Date to extract fields from the created LocalDate
throws:
  IllegalArgumentException - if the calendar is null
throws:
  IllegalArgumentException - if the date is invalid for the ISO chronology




get
public int get(DateTimeFieldType fieldType)(Code)
Get the value of one of the fields of a datetime.

This method gets the value of the specified field. For example:

 LocalDate dt = LocalDate.nowDefaultZone();
 int year = dt.get(DateTimeFieldType.year());
 

Parameters:
  fieldType - a field type, usually obtained from DateTimeFieldType, not null the value of that field
throws:
  IllegalArgumentException - if the field type is null or unsupported



getCenturyOfEra
public int getCenturyOfEra()(Code)
Get the year of era field value. the year of era



getChronology
public Chronology getChronology()(Code)
Gets the chronology of the date. the Chronology that the date is using



getDayOfMonth
public int getDayOfMonth()(Code)
Get the day of month field value.

The values for the day of month are defined in org.joda.time.DateTimeConstants . the day of month




getDayOfWeek
public int getDayOfWeek()(Code)
Get the day of week field value.

The values for the day of week are defined in org.joda.time.DateTimeConstants . the day of week




getDayOfYear
public int getDayOfYear()(Code)
Get the day of year field value. the day of year



getEra
public int getEra()(Code)
Get the era field value. the era



getField
protected DateTimeField getField(int index, Chronology chrono)(Code)
Gets the field for a specific index in the chronology specified.

This method must not use any instance variables.
Parameters:
  index - the index to retrieve
Parameters:
  chrono - the chronology to use the field




getLocalMillis
protected long getLocalMillis()(Code)
Gets the local milliseconds from the Java epoch of 1970-01-01T00:00:00 (not fixed to any specific time zone). the number of milliseconds since 1970-01-01T00:00:00
since:
   1.5 (previously private)



getMonthOfYear
public int getMonthOfYear()(Code)
Get the month of year field value. the month of year



getValue
public int getValue(int index)(Code)
Gets the value of the field at the specifed index.

This method is required to support the ReadablePartial interface. The supported fields are Year, MonthOfYear and DayOfMonth. Note that all fields from day and above may in fact be queried via other methods.
Parameters:
  index - the index, zero to two the value
throws:
  IndexOutOfBoundsException - if the index is invalid




getWeekOfWeekyear
public int getWeekOfWeekyear()(Code)
Get the week of weekyear field value. the week of a week based year



getWeekyear
public int getWeekyear()(Code)
Get the weekyear field value.

The weekyear is the year that matches with the weekOfWeekyear field. In the standard ISO8601 week algorithm, the first week of the year is that in which at least 4 days are in the year. As a result of this definition, day 1 of the first week may be in the previous year. The weekyear allows you to query the effective year for that day. the weekyear




getYear
public int getYear()(Code)
Get the year field value. the year



getYearOfCentury
public int getYearOfCentury()(Code)
Get the year of century field value. the year of century



getYearOfEra
public int getYearOfEra()(Code)
Get the year of era field value. the year of era



isSupported
public boolean isSupported(DateTimeFieldType type)(Code)
Checks if the field type specified is supported by this local date and chronology. This can be used to avoid exceptions in LocalDate.get(DateTimeFieldType) .
Parameters:
  type - a field type, usually obtained from DateTimeFieldType true if the field type is supported



isSupported
public boolean isSupported(DurationFieldType type)(Code)
Checks if the duration type specified is supported by this local date and chronology.
Parameters:
  type - a duration type, usually obtained from DurationFieldType true if the field type is supported



minus
public LocalDate minus(ReadablePeriod period)(Code)
Returns a copy of this date with the specified period taken away.

If the amount is zero or null, then this is returned.

This method is typically used to subtract complex period instances. Subtracting one field is best achieved using methods like LocalDate.minusYears(int) .

Unsupported time fields are ignored, thus subtracting a period of 24 hours will not have any effect.
Parameters:
  period - the period to reduce this instant by a copy of this LocalDate with the period taken away
throws:
  ArithmeticException - if the result exceeds the internal capacity




minusDays
public LocalDate minusDays(int days)(Code)
Returns a copy of this date minus the specified number of days.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate subtracted = dt.minusDays(6);
 LocalDate subtracted = dt.minus(Period.days(6));
 LocalDate subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);
 

Parameters:
  days - the amount of days to subtract, may be negative the new LocalDate minus the increased days



minusMonths
public LocalDate minusMonths(int months)(Code)
Returns a copy of this date minus the specified number of months.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate subtracted = dt.minusMonths(6);
 LocalDate subtracted = dt.minus(Period.months(6));
 LocalDate subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);
 

Parameters:
  months - the amount of months to subtract, may be negative the new LocalDate minus the increased months



minusWeeks
public LocalDate minusWeeks(int weeks)(Code)
Returns a copy of this date minus the specified number of weeks.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate subtracted = dt.minusWeeks(6);
 LocalDate subtracted = dt.minus(Period.weeks(6));
 LocalDate subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6);
 

Parameters:
  weeks - the amount of weeks to subtract, may be negative the new LocalDate minus the increased weeks



minusYears
public LocalDate minusYears(int years)(Code)
Returns a copy of this date minus the specified number of years.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate subtracted = dt.minusYears(6);
 LocalDate subtracted = dt.minus(Period.years(6));
 LocalDate subtracted = dt.withFieldAdded(DurationFieldType.years(), -6);
 

Parameters:
  years - the amount of years to subtract, may be negative the new LocalDate minus the increased years



monthOfYear
public Property monthOfYear()(Code)
Get the month of year property which provides access to advanced functionality. the month of year property



plus
public LocalDate plus(ReadablePeriod period)(Code)
Returns a copy of this date with the specified period added.

If the amount is zero or null, then this is returned.

This method is typically used to add complex period instances. Adding one field is best achieved using methods like LocalDate.plusYears(int) .

Unsupported time fields are ignored, thus adding a period of 24 hours will not have any effect.
Parameters:
  period - the period to add to this one, null means zero a copy of this date with the period added
throws:
  ArithmeticException - if the result exceeds the internal capacity




plusDays
public LocalDate plusDays(int days)(Code)
Returns a copy of this date plus the specified number of days.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate added = dt.plusDays(6);
 LocalDate added = dt.plus(Period.days(6));
 LocalDate added = dt.withFieldAdded(DurationFieldType.days(), 6);
 

Parameters:
  days - the amount of days to add, may be negative the new LocalDate plus the increased days



plusMonths
public LocalDate plusMonths(int months)(Code)
Returns a copy of this date plus the specified number of months.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate added = dt.plusMonths(6);
 LocalDate added = dt.plus(Period.months(6));
 LocalDate added = dt.withFieldAdded(DurationFieldType.months(), 6);
 

Parameters:
  months - the amount of months to add, may be negative the new LocalDate plus the increased months



plusWeeks
public LocalDate plusWeeks(int weeks)(Code)
Returns a copy of this date plus the specified number of weeks.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate added = dt.plusWeeks(6);
 LocalDate added = dt.plus(Period.weeks(6));
 LocalDate added = dt.withFieldAdded(DurationFieldType.weeks(), 6);
 

Parameters:
  weeks - the amount of weeks to add, may be negative the new LocalDate plus the increased weeks



plusYears
public LocalDate plusYears(int years)(Code)
Returns a copy of this date plus the specified number of years.

This LocalDate instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

 LocalDate added = dt.plusYears(6);
 LocalDate added = dt.plus(Period.years(6));
 LocalDate added = dt.withFieldAdded(DurationFieldType.years(), 6);
 

Parameters:
  years - the amount of years to add, may be negative the new LocalDate plus the increased years



property
public Property property(DateTimeFieldType fieldType)(Code)
Gets the property object for the specified type, which contains many useful methods.
Parameters:
  fieldType - the field type to get the chronology for 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, which is three. The supported fields are Year, MonthOfYear and DayOfMonth. Note that all fields from day and above may in fact be queried via other methods. the field count, three



toDateMidnight
public DateMidnight toDateMidnight()(Code)
Converts this LocalDate to a DateMidnight in the default time zone.

As from v1.5, you are recommended to avoid DateMidnight and use LocalDate.toDateTimeAtStartOfDay() instead because of the exception detailed below.

This method will throw an exception if the default time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

This instance is immutable and unaffected by this method call. the DateMidnight instance in the default zone




toDateMidnight
public DateMidnight toDateMidnight(DateTimeZone zone)(Code)
Converts this LocalDate to a DateMidnight.

As from v1.5, you are recommended to avoid DateMidnight and use LocalDate.toDateTimeAtStartOfDay() instead because of the exception detailed below.

This method will throw an exception if the time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

This instance is immutable and unaffected by this method call.
Parameters:
  zone - the zone to get the DateMidnight in, null means default zone the DateMidnight instance




toDateTime
public DateTime toDateTime(LocalTime time)(Code)
Converts this object to a DateTime using a LocalTime to fill in the missing fields and using the default time zone.

The resulting chronology is determined by the chronology of this LocalDate. The chronology of the time must match. If the time is null, the current time in the date's chronology is used.

This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

This instance is immutable and unaffected by this method call.
Parameters:
  time - the time of day to use, null means current time the DateTime instance
throws:
  IllegalArgumentException - if the chronology of the time does not match




toDateTime
public DateTime toDateTime(LocalTime time, DateTimeZone zone)(Code)
Converts this object to a DateTime using a LocalTime to fill in the missing fields.

The resulting chronology is determined by the chronology of this LocalDate plus the time zone. The chronology of the time must match. If the time is null, the current time in the date's chronology is used.

This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

This instance is immutable and unaffected by this method call.
Parameters:
  time - the time of day to use, null means current time
Parameters:
  zone - the zone to get the DateTime in, null means default the DateTime instance
throws:
  IllegalArgumentException - if the chronology of the time does not match




toDateTimeAtCurrentTime
public DateTime toDateTimeAtCurrentTime()(Code)
Converts this LocalDate to a full datetime using the default time zone setting the date fields from this instance and the time fields from the current time.

This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

This instance is immutable and unaffected by this method call. this date as a datetime with the time as the current time




toDateTimeAtCurrentTime
public DateTime toDateTimeAtCurrentTime(DateTimeZone zone)(Code)
Converts this LocalDate to a full datetime using the specified time zone setting the date fields from this instance and the time fields from the current time.

This method uses the chronology from this instance plus the time zone specified.

This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

This instance is immutable and unaffected by this method call.
Parameters:
  zone - the zone to use, null means default zone this date as a datetime with the time as the current time




toDateTimeAtMidnight
public DateTime toDateTimeAtMidnight()(Code)
Converts this LocalDate to a full datetime at midnight using the default time zone.

This method will throw an exception if the default time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

This instance is immutable and unaffected by this method call. this date as a datetime at midnightLocalDate.toDateTimeAtStartOfDay()




toDateTimeAtMidnight
public DateTime toDateTimeAtMidnight(DateTimeZone zone)(Code)
Converts this LocalDate to a full datetime at midnight using the specified time zone.

This method will throw an exception if the time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

This method uses the chronology from this instance plus the time zone specified.

This instance is immutable and unaffected by this method call.
Parameters:
  zone - the zone to use, null means default zone this date as a datetime at midnightLocalDate.toDateTimeAtStartOfDay(DateTimeZone)




toDateTimeAtStartOfDay
public DateTime toDateTimeAtStartOfDay()(Code)
Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.

The time will normally be midnight, as that is the earliest time on any given day. However, in some time zones when Daylight Savings Time starts, there is no midnight because time jumps from 11:59 to 01:00. This method handles that situation by returning 01:00 on that date.

This instance is immutable and unaffected by this method call. this date as a datetime at the start of the day
since:
   1.5




toDateTimeAtStartOfDay
public DateTime toDateTimeAtStartOfDay(DateTimeZone zone)(Code)
Converts this LocalDate to a full datetime at the earliest valid time for the date using the specified time zone.

The time will normally be midnight, as that is the earliest time on any given day. However, in some time zones when Daylight Savings Time starts, there is no midnight because time jumps from 11:59 to 01:00. This method handles that situation by returning 01:00 on that date.

This method uses the chronology from this instance plus the time zone specified.

This instance is immutable and unaffected by this method call.
Parameters:
  zone - the zone to use, null means default zone this date as a datetime at the start of the day
since:
   1.5




toInterval
public Interval toInterval()(Code)
Converts this object to an Interval representing the whole day in the default time zone.

This instance is immutable and unaffected by this method call. a interval over the day




toInterval
public Interval toInterval(DateTimeZone zone)(Code)
Converts this object to an Interval representing the whole day.

This instance is immutable and unaffected by this method call.
Parameters:
  zone - the zone to get the Interval in, null means default a interval over the day




toLocalDateTime
public LocalDateTime toLocalDateTime(LocalTime time)(Code)
Converts this object to a LocalDateTime using a LocalTime to fill in the missing fields.

The resulting chronology is determined by the chronology of this LocalDate. The chronology of the time must also match. If the time is null an exception is thrown.

This instance is immutable and unaffected by this method call.
Parameters:
  time - the time of day to use, must not be null the LocalDateTime instance
throws:
  IllegalArgumentException - if the time is null
throws:
  IllegalArgumentException - if the chronology of the time does not match
since:
   1.5




toString
public String toString()(Code)
Output the date time in ISO8601 format (yyyy-MM-dd). ISO8601 time formatted string.



toString
public String toString(String pattern)(Code)
Output the date using the specified format pattern.
Parameters:
  pattern - the pattern specification, null means use toString
See Also:   org.joda.time.format.DateTimeFormat



toString
public String toString(String pattern, Locale locale) throws IllegalArgumentException(Code)
Output the date using the specified format pattern.
Parameters:
  pattern - the pattern specification, null means use toString
Parameters:
  locale - Locale to use, null means default
See Also:   org.joda.time.format.DateTimeFormat



weekOfWeekyear
public Property weekOfWeekyear()(Code)
Get the week of a week based year property which provides access to advanced functionality. the week of a week based year property



weekyear
public Property weekyear()(Code)
Get the weekyear property which provides access to advanced functionality. the weekyear property



withCenturyOfEra
public LocalDate withCenturyOfEra(int centuryOfEra)(Code)
Returns a copy of this date with the century of era field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of century of era changed.
Parameters:
  centuryOfEra - the centurey of era to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withDayOfMonth
public LocalDate withDayOfMonth(int dayOfMonth)(Code)
Returns a copy of this date with the day of month field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of month changed.
Parameters:
  dayOfMonth - the day of month to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withDayOfWeek
public LocalDate withDayOfWeek(int dayOfWeek)(Code)
Returns a copy of this date with the day of week field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of week changed.
Parameters:
  dayOfWeek - the day of week to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withDayOfYear
public LocalDate withDayOfYear(int dayOfYear)(Code)
Returns a copy of this date with the day of year field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of year changed.
Parameters:
  dayOfYear - the day of year to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withEra
public LocalDate withEra(int era)(Code)
Returns a copy of this date with the era field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of era changed.
Parameters:
  era - the era to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




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

For example, if the field type is monthOfYear then the month of year field will be changed in the returned instance. If the field type is null, then this is returned.

These two lines are equivalent:

 LocalDate updated = dt.withDayOfMonth(6);
 LocalDate updated = dt.withField(DateTimeFieldType.dayOfMonth(), 6);
 

Parameters:
  fieldType - the field type to set, not null
Parameters:
  value - the value to set a copy of this date with the field set
throws:
  IllegalArgumentException - if the field is null or unsupported



withFieldAdded
public LocalDate withFieldAdded(DurationFieldType fieldType, int amount)(Code)
Returns a copy of this date with the value of the specified field increased.

If the addition is zero or the field is null, then this is returned.

These three lines are equivalent:

 LocalDate added = dt.withFieldAdded(DurationFieldType.years(), 6);
 LocalDate added = dt.plusYears(6);
 LocalDate added = dt.plus(Period.years(6));
 

Parameters:
  fieldType - the field type to add to, not null
Parameters:
  amount - the amount to add a copy of this date with the field updated
throws:
  IllegalArgumentException - if the field is null or unsupported
throws:
  ArithmeticException - if the result exceeds the internal capacity



withFields
public LocalDate withFields(ReadablePartial partial)(Code)
Returns a copy of this date with the partial set of fields replacing those from this instance.

For example, if the partial contains a year and a month then those two fields will be changed in the returned instance. Unsupported fields are ignored. If the partial is null, then this is returned.
Parameters:
  partial - the partial set of fields to apply to this date, null ignored a copy of this date with a different set of fields
throws:
  IllegalArgumentException - if any value is invalid




withLocalMillis
LocalDate withLocalMillis(long newMillis)(Code)
Returns a copy of this date with different local millis.

The returned object will be a new instance of the same type. Only the millis will change, the chronology is kept. The returned object will be either be a new instance or this.
Parameters:
  newMillis - the new millis, from 1970-01-01T00:00:00 a copy of this date with different millis




withMonthOfYear
public LocalDate withMonthOfYear(int monthOfYear)(Code)
Returns a copy of this date with the month of year field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of month of year changed.
Parameters:
  monthOfYear - the month of year to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withPeriodAdded
public LocalDate withPeriodAdded(ReadablePeriod period, int scalar)(Code)
Returns a copy of this date with the specified period added.

If the addition is zero, then this is returned.

This method is typically used to add multiple copies of complex period instances. Adding one field is best achieved using methods like LocalDate.withFieldAdded(DurationFieldType,int) or LocalDate.plusYears(int) .

Unsupported time fields are ignored, thus adding a period of 24 hours will not have any effect.
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 date with the period added
throws:
  ArithmeticException - if the result exceeds the internal capacity




withWeekOfWeekyear
public LocalDate withWeekOfWeekyear(int weekOfWeekyear)(Code)
Returns a copy of this date with the week of weekyear field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of week of weekyear changed.
Parameters:
  weekOfWeekyear - the week of weekyear to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withWeekyear
public LocalDate withWeekyear(int weekyear)(Code)
Returns a copy of this date with the weekyear field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of weekyear changed.
Parameters:
  weekyear - the weekyear to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withYear
public LocalDate withYear(int year)(Code)
Returns a copy of this date with the year field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of year changed.
Parameters:
  year - the year to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withYearOfCentury
public LocalDate withYearOfCentury(int yearOfCentury)(Code)
Returns a copy of this date with the year of century field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of year of century changed.
Parameters:
  yearOfCentury - the year of century to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




withYearOfEra
public LocalDate withYearOfEra(int yearOfEra)(Code)
Returns a copy of this date with the year of era field updated.

LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of year of era changed.
Parameters:
  yearOfEra - the year of era to set a copy of this object with the field set
throws:
  IllegalArgumentException - if the value is invalid




year
public Property year()(Code)
Get the year property which provides access to advanced functionality. the year property



yearOfCentury
public Property yearOfCentury()(Code)
Get the year of century property which provides access to advanced functionality. the year of era property



yearOfEra
public Property yearOfEra()(Code)
Get the year of era property which provides access to advanced functionality. the year of era property



Methods inherited from org.joda.time.base.BaseLocal
abstract protected long getLocalMillis()(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.