Joda Time API

org.joda.time.chrono.gj
Class GJChronology

java.lang.Object
  |
  +--org.joda.time.Chronology
        |
        +--org.joda.time.chrono.gj.GJChronology
All Implemented Interfaces:
java.io.Serializable

public abstract class GJChronology
extends Chronology

GJChronology provides access to the individual date time fields for the Gregorian/Julian defined chronological calendar system.

The Gregorian calendar replaced the Julian calendar, and the point in time when this chronology switches can be controlled using the second parameter of the getInstance method. By default this cutover is set to the date the Gregorian calendar was first instituted, October 15, 1582.

Before this date, this chronology uses the proleptic Julian calendar (proleptic means extending indefinitely). The Julian calendar has leap years every four years, whereas the Gregorian has special rules for 100 and 400 years. A meaningful result will thus be obtained for all input values. However before March 1, 4 CE, Julian leap years were irregular, and before 45 BCE there was no Julian calendar.

This chronology differs from java.util.GregorianCalendar in that years in BCE are returned correctly. Thus year 1 BCE is returned as -1 instead of 1. The yearOfEra field produces results compatible with GregorianCalendar.

The Julian calendar does not have a year zero, and so year -1 is followed by year 1. If the Gregorian cutover date is specified at or before year -1 (Julian), year zero is defined. In other words, the proleptic Gregorian chronology implemented by this class has a year zero.

A pure proleptic Gregorian chronology is obtained by specifying a cutover of Long.MIN_VALUE. Likewise, a pure Julian chronology is obtained with a cutover of Long.MAX_VALUE.

Since:
1.0
Author:
Stephen Colebourne, Brian S O'Neill
See Also:
Serialized Form

Method Summary
 DateTimeField centuryOfEra()
          Get the century of era field for this chronology.
 DateTimeField clockhourOfDay()
          Get the hour of day (offset to 1-24) field for this chronology.
 DateTimeField clockhourOfHalfday()
          Get the hour of am/pm (offset to 1-12) field for this chronology.
 DateTimeField dayOfMonth()
          Get the day of month field for this chronology.
 DateTimeField dayOfWeek()
          Get the day of week field for this chronology.
 DateTimeField dayOfYear()
          Get the day of year field for this chronology.
 DateTimeField era()
          Get the era field for this chronology.
 DateTimeZone getDateTimeZone()
          Returns the DateTimeZone that this Chronology operates in, or null if unspecified.
 Instant getGregorianJulianCutover()
          Gets the cutover instant between Gregorian and Julian chronologies.
abstract  long getGregorianJulianCutoverMillis()
          Gets the cutover millis between Gregorian and Julian chronologies.
static GJChronology getInstance()
          Factory method returns instances of the default GJ chronology.
static GJChronology getInstance(DateTimeZone zone)
          Factory method returns instances of the default GJ chronology.
static GJChronology getInstance(DateTimeZone zone, long gregorianCutover, boolean centuryISO)
          Factory method allowing the Gregorian cutover point and year zero handling to be set.
static GJChronology getInstance(DateTimeZone zone, long gregorianCutover, boolean centuryISO, int minDaysInFirstWeek)
          Factory method allowing the Gregorian cutover point and year zero handling to be set.
static GJChronology getInstance(DateTimeZone zone, ReadableInstant gregorianCutover, boolean centuryISO)
          Factory method allowing the Gregorian cutover point and year zero handling to be set.
static GJChronology getInstance(DateTimeZone zone, ReadableInstant gregorianCutover, boolean centuryISO, int minDaysInFirstWeek)
          Factory method allowing the Gregorian cutover point and year zero handling to be set.
static GJChronology getInstanceUTC()
          Factory method returns instances of the default GJ chronology.
abstract  int getMinimumDaysInFirstWeek()
           
 DateTimeField halfdayOfDay()
          Get the AM(0) PM(1) field for this chronology.
 DateTimeField hourOfDay()
          Get the hour of day (0-23) field for this chronology.
 DateTimeField hourOfHalfday()
          Get the hour of am/pm (0-11) field for this chronology.
abstract  boolean isCenturyISO()
          Returns true when century fields follow ISO rules.
 DateTimeField millisOfDay()
          Get the millis of day field for this chronology.
 DateTimeField millisOfSecond()
          Get the millis of second field for this chronology.
 DateTimeField minuteOfDay()
          Get the minute of day field for this chronology.
 DateTimeField minuteOfHour()
          Get the minute of hour field for this chronology.
 DateTimeField monthOfYear()
          Get the month of year field for this chronology.
 DateTimeField secondOfDay()
          Get the second of day field for this chronology.
 DateTimeField secondOfMinute()
          Get the second of minute field for this chronology.
 DateTimeField weekOfWeekyear()
          Get the week of a week based year field for this chronology.
 DateTimeField weekyear()
          Get the year of a week based year field for this chronology.
 Chronology withDateTimeZone(DateTimeZone zone)
          Returns an instance of this Chronology that operates in any time zone.
 DateTimeField year()
          Get the year field for this chronology.
 DateTimeField yearOfCentury()
          Get the year of century field for this chronology.
 DateTimeField yearOfEra()
          Get the year of era field for this chronology.
 
Methods inherited from class org.joda.time.Chronology
getDateOnlyMillis, getTimeOnlyMillis, withUTC
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstanceUTC

public static GJChronology getInstanceUTC()
Factory method returns instances of the default GJ chronology. This uses a cutover date of October 15, 1582 (Gregorian) 00:00:00 UTC. For this value, October 4, 1582 (Julian) is followed by October 15, 1582 (Gregorian).

The first day of the week is designated to be Monday, and the minimum days in the first week of the year is 4.

The time zone of the returned instance is UTC.


getInstance

public static GJChronology getInstance()
Factory method returns instances of the default GJ chronology. This uses a cutover date of October 15, 1582 (Gregorian) 00:00:00 UTC. For this value, October 4, 1582 (Julian) is followed by October 15, 1582 (Gregorian).

The first day of the week is designated to be Monday, and the minimum days in the first week of the year is 4.

The returned chronology is in the default time zone.


getInstance

public static GJChronology getInstance(DateTimeZone zone)
Factory method returns instances of the default GJ chronology. This uses a cutover date of October 15, 1582 (Gregorian) 00:00:00 UTC. For this value, October 4, 1582 (Julian) is followed by October 15, 1582 (Gregorian).

The first day of the week is designated to be Monday, and the minimum days in the first week of the year is 4.

Parameters:
zone - the time zone to use, null is default

getInstance

public static GJChronology getInstance(DateTimeZone zone,
                                       ReadableInstant gregorianCutover,
                                       boolean centuryISO)
Factory method allowing the Gregorian cutover point and year zero handling to be set. If the cutover millis is Long.MIN_VALUE, a proleptic Gregorian calendar is returned. If the cutover millis is Long.MAX_VALUE, a proleptic Julian calendar is returned.

The first day of the week is designated to be Monday, and the minimum days in the first week of the year is 4.

Parameters:
zone - the time zone to use, null is default
gregorianCutover - the cutover as a ReadableInstant, null means default
centuryISO - when true, century related fields follow ISO rules

getInstance

public static GJChronology getInstance(DateTimeZone zone,
                                       long gregorianCutover,
                                       boolean centuryISO)
Factory method allowing the Gregorian cutover point and year zero handling to be set. If the cutover is Long.MIN_VALUE, a proleptic Gregorian calendar is returned. If the cutover is Long.MAX_VALUE, a proleptic Julian calendar is returned.

The first day of the week is designated to be Monday, and the minimum days in the first week of the year is 4.

Parameters:
zone - the time zone to use, null is default
gregorianCutover - the cutover as milliseconds from 1970-01-01T00:00:00Z
centuryISO - when true, century related fields follow ISO rules

getInstance

public static GJChronology getInstance(DateTimeZone zone,
                                       ReadableInstant gregorianCutover,
                                       boolean centuryISO,
                                       int minDaysInFirstWeek)
Factory method allowing the Gregorian cutover point and year zero handling to be set. If the cutover is Long.MIN_VALUE, a proleptic Gregorian calendar is returned. If the cutover is Long.MAX_VALUE, a proleptic Julian calendar is returned.

Parameters:
zone - the time zone to use, null is default
gregorianCutover - the cutover as a ReadableInstant, null means default
centuryISO - when true, century related fields follow ISO rules
minDaysInFirstWeek - minimum number of days in first week of the year; ISO is 4

getInstance

public static GJChronology getInstance(DateTimeZone zone,
                                       long gregorianCutover,
                                       boolean centuryISO,
                                       int minDaysInFirstWeek)
Factory method allowing the Gregorian cutover point and year zero handling to be set. If the cutover is Long.MIN_VALUE, a proleptic Gregorian calendar is returned. If the cutover is Long.MAX_VALUE, a proleptic Julian calendar is returned.

Parameters:
zone - the time zone to use, null is default
gregorianCutover - the cutover as milliseconds from 1970-01-01T00:00:00Z
centuryISO - when true, century related fields follow ISO rules
minDaysInFirstWeek - minimum number of days in first week of the year; ISO is 4

withDateTimeZone

public Chronology withDateTimeZone(DateTimeZone zone)
Description copied from class: Chronology
Returns an instance of this Chronology that operates in any time zone.

Specified by:
withDateTimeZone in class Chronology
Returns:
a version of this chronology with a specific time zone
See Also:
ZonedChronology

getDateTimeZone

public DateTimeZone getDateTimeZone()
Description copied from class: Chronology
Returns the DateTimeZone that this Chronology operates in, or null if unspecified.

Specified by:
getDateTimeZone in class Chronology
Returns:
DateTimeZone null if unspecified

getGregorianJulianCutover

public Instant getGregorianJulianCutover()
Gets the cutover instant between Gregorian and Julian chronologies.

Returns:
the cutover instant

getGregorianJulianCutoverMillis

public abstract long getGregorianJulianCutoverMillis()
Gets the cutover millis between Gregorian and Julian chronologies.

Returns:
the cutover millis

isCenturyISO

public abstract boolean isCenturyISO()
Returns true when century fields follow ISO rules. In ISO rules, the century is simply the year divided by 100, and the year of century is the remainder.

When false is returned, the first century is defined to start on year one, and the year of century can range from 1 to 100.


getMinimumDaysInFirstWeek

public abstract int getMinimumDaysInFirstWeek()

millisOfSecond

public DateTimeField millisOfSecond()
Description copied from class: Chronology
Get the millis of second field for this chronology.

Overrides:
millisOfSecond in class Chronology
Returns:
DateTimeField

millisOfDay

public DateTimeField millisOfDay()
Description copied from class: Chronology
Get the millis of day field for this chronology.

Overrides:
millisOfDay in class Chronology
Returns:
DateTimeField

secondOfMinute

public DateTimeField secondOfMinute()
Description copied from class: Chronology
Get the second of minute field for this chronology.

Overrides:
secondOfMinute in class Chronology
Returns:
DateTimeField

secondOfDay

public DateTimeField secondOfDay()
Description copied from class: Chronology
Get the second of day field for this chronology.

Overrides:
secondOfDay in class Chronology
Returns:
DateTimeField

minuteOfHour

public DateTimeField minuteOfHour()
Description copied from class: Chronology
Get the minute of hour field for this chronology.

Overrides:
minuteOfHour in class Chronology
Returns:
DateTimeField

minuteOfDay

public DateTimeField minuteOfDay()
Description copied from class: Chronology
Get the minute of day field for this chronology.

Overrides:
minuteOfDay in class Chronology
Returns:
DateTimeField

hourOfDay

public DateTimeField hourOfDay()
Description copied from class: Chronology
Get the hour of day (0-23) field for this chronology.

Overrides:
hourOfDay in class Chronology
Returns:
DateTimeField

clockhourOfDay

public DateTimeField clockhourOfDay()
Description copied from class: Chronology
Get the hour of day (offset to 1-24) field for this chronology.

Overrides:
clockhourOfDay in class Chronology
Returns:
DateTimeField

hourOfHalfday

public DateTimeField hourOfHalfday()
Description copied from class: Chronology
Get the hour of am/pm (0-11) field for this chronology.

Overrides:
hourOfHalfday in class Chronology
Returns:
DateTimeField

clockhourOfHalfday

public DateTimeField clockhourOfHalfday()
Description copied from class: Chronology
Get the hour of am/pm (offset to 1-12) field for this chronology.

Overrides:
clockhourOfHalfday in class Chronology
Returns:
DateTimeField

halfdayOfDay

public DateTimeField halfdayOfDay()
Description copied from class: Chronology
Get the AM(0) PM(1) field for this chronology.

Overrides:
halfdayOfDay in class Chronology
Returns:
DateTimeField

dayOfWeek

public DateTimeField dayOfWeek()
Description copied from class: Chronology
Get the day of week field for this chronology.

DayOfWeek values are defined in DateTimeConstants. They use the ISO definitions, where 1 is Monday and 7 is Sunday.

Overrides:
dayOfWeek in class Chronology
Returns:
DateTimeField

dayOfMonth

public DateTimeField dayOfMonth()
Description copied from class: Chronology
Get the day of month field for this chronology.

Overrides:
dayOfMonth in class Chronology
Returns:
DateTimeField

dayOfYear

public DateTimeField dayOfYear()
Description copied from class: Chronology
Get the day of year field for this chronology.

Overrides:
dayOfYear in class Chronology
Returns:
DateTimeField

weekOfWeekyear

public DateTimeField weekOfWeekyear()
Description copied from class: Chronology
Get the week of a week based year field for this chronology.

Overrides:
weekOfWeekyear in class Chronology
Returns:
DateTimeField

weekyear

public DateTimeField weekyear()
Description copied from class: Chronology
Get the year of a week based year field for this chronology.

Overrides:
weekyear in class Chronology
Returns:
DateTimeField

monthOfYear

public DateTimeField monthOfYear()
Description copied from class: Chronology
Get the month of year field for this chronology.

Overrides:
monthOfYear in class Chronology
Returns:
DateTimeField

year

public DateTimeField year()
Description copied from class: Chronology
Get the year field for this chronology.

Overrides:
year in class Chronology
Returns:
DateTimeField

yearOfEra

public DateTimeField yearOfEra()
Description copied from class: Chronology
Get the year of era field for this chronology.

Overrides:
yearOfEra in class Chronology
Returns:
DateTimeField

yearOfCentury

public DateTimeField yearOfCentury()
Description copied from class: Chronology
Get the year of century field for this chronology.

Overrides:
yearOfCentury in class Chronology
Returns:
DateTimeField

centuryOfEra

public DateTimeField centuryOfEra()
Description copied from class: Chronology
Get the century of era field for this chronology.

Overrides:
centuryOfEra in class Chronology
Returns:
DateTimeField

era

public DateTimeField era()
Description copied from class: Chronology
Get the era field for this chronology.

Overrides:
era in class Chronology
Returns:
DateTimeField

Joda Time API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.