alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (cal_gregorian.xml)

This example Java source code file (cal_gregorian.xml) is included in the alvinalexander.com "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, gregorian, gregorianjulian, isbn, iso, iso-8859-1, joda-time, see, the, this, using

The cal_gregorian.xml Java example source code

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

<document>

 <properties>
  <title>Java date and time API - Gregorian calendar system
  <author>Stephen Colebourne
 </properties>

 <body>

<section name="Gregorian calendar system">
<p>
The Gregorian calendar system is calendar system used by most of the modern business world.
It was first introduced on 1582-10-15 replacing the <a href="cal_julian.html">Julian calendar.
Gregorian rules define a leap year as once every four years, except every 100, but including every 400.
</p>
<p>
The Gregorian chronology in Joda-Time is equivalent* to the ISO chronology, and uses
Gregorian rules for all time. Thus it is not historically accurate before 1583.
This also means that the Gregorian chronology does not correspond to the java class
<code>GregorianCalendar. See GregorianJulian for a
suitable replacement.
</p>
<p>
* The Gregorian and ISO chronologies do in fact differ slightly.
The Gregorian chronology defines a century as it is spoken,
thus 2005 is in the 21st century.
The ISO chronology defines a century as the first two digits of the year,
thus 2005 has a century field of 20.
</p>
<p>
References
<ul>
<li>Calendrical Calculations - Millenium Edition - ISBN 0521777526
<li>Wikipedia - Gregorian Calendar
</ul>
</p>
</section>

<section name="Using Gregorian chronology in Joda-Time">
<p>
Within Joda-Time the Gregorian calendar system can be used by obtaining an
instance of <a href="apidocs/org/joda/time/chrono/GregorianChronology.html">GregorianChronology.
This is normally created using the factory method
<a href="apidocs/org/joda/time/chrono/GregorianChronology.html#getInstance()">GregorianChronology.getInstance().
This is then passed into the constructors of the main date and time classes.
</p>
<source>
// setup date object for midday on Christmas 2004
Chronology chrono = GregorianChronology.getInstance();
DateTime dt = new DateTime(2004, 12, 25, 12, 0, 0, 0, chrono);
</source>

</section>

</body>
</document>

Other Java examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
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.