| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (key_chronology.xml)

This example Java source code file (key_chronology.xml) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

api, chronology, colebourne, datetime, datetimezone, good, iso, iso-8859-1, jdk, joda-time, the, this, thus

The key_chronology.xml Java example source code

<?xml version="1.0" encoding="ISO-8859-1"?>


  <title>Java date and time API - Chronology
  <author>Stephen Colebourne


<section name="Chronology">

A <i>chronology in Joda-Time is a pluggable calendar system.
The JDK supports multiple calendar systems via subclasses of <code>Calendar.
This is clunky, and in practice it is very difficult to write another calendar system.
Joda-Time supports multiple calendar systems by designing a pluggable system.
The default chronology in Joda-Time is <a href="cal_iso.html">ISO.
This calendar system is the same as that used by business in the majority of the world today.
The ISO system is unsuitable for historical work before 1583 as it applies the leap year rules
from today back in time (it is a proleptic calendar).
As a result, users requiring a more historically accurate calendar system are forced to
think about their actual requirements, which we believe is a Good Thing.
The actual calculations of the chronology are split between the
<a href="apidocs/org/joda/time/Chronology.html">Chronology class itself
and the field classes -
<a href="apidocs/org/joda/time/DateTimeField.html">DateTimeField and
<a href="apidocs/org/joda/time/DurationField.html">DurationField.
Together, the subclasses of these three classes form the bulk of the code in the library.
However, most users will never need to use or refer directly to the subclasses.
Instead, most applications will simply obtain the chronology and use it as a singleton.
The chronology class also supports the time zone functionality.
This is applied to the underlying chronology via the decorator design pattern.
The <a href="apidocs/org/joda/time/DateTimeZone.html">DateTimeZone class provides
access to the zones via factories, and also supports a default zone concept.
A full list of time zones can be found <a href="timezones.html">here.
It is also possible to <a href="tz_update.html">update the zone data yourself.
Internally, all the chronology, field and time zone classes are maintained as singletons.
Thus there is an initial setup cost when using Joda-Time, but after that only
the main API instance classes (DateTime, Interval, Period, etc.) have creation and
garbage collector costs.
Reference documentation is provided for each of the <a href="cal.html">8 calendar systems
that Joda-Time includes.


<section name="Using Chronology in Joda-Time">
A Chronology is obtained and used in Joda-Time as a singleton:
DateTimeZone zone = DateTimeZone.forID("Europe/London");
Chronology coptic = CopticChronology.getInstance(zone);

// current time with coptic chronology
DateTime dt = new DateTime(coptic);

int year = dt.getYear();   // gets the current coptic year
int month = dt.getMonthOfYear(); // gets the current coptic month

<subsection name="Nulls">
A null chronology always refers to ISO chronology in the default zone.
Thus, when a method is defined as taking a <code>Chronology, passing null in
will be the same as passing in the ISO chronology in the default time zone.



Other Java examples (source code examples)

Here is a short list of links related to this Java key_chronology.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.