📄 bigdate.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_07) on Tue Jul 08 17:25:13 PDT 2008 -->
<TITLE>
BigDate
</TITLE>
<META NAME="date" CONTENT="2008-07-08">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="BigDate";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../com/mindprod/common11/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/BigDate.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
<A HREF="../../../com/mindprod/common11/Build.html" title="class in com.mindprod.common11"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?com/mindprod/common11/BigDate.html" target="_top"><B>FRAMES</B></A>
<A HREF="BigDate.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.mindprod.common11</FONT>
<BR>
Class BigDate</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.mindprod.common11.BigDate</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable, java.lang.Cloneable, java.lang.Comparable</DD>
</DL>
<HR>
<DL>
<DT><PRE>public final class <B>BigDate</B><DT>extends java.lang.Object<DT>implements java.lang.Cloneable, java.io.Serializable, java.lang.Comparable</DL>
</PRE>
<P>
Convert Gregorian YYYY MM DD back and forth to ordinal days since 1970 Jan 1, Thursday (sometimes called Julian or datestamp form). BigDate objects are not designed for <b>storing</b> dates in a database, just for conversion. Long term storage should store the ordinal either as an int, or possibly as a short. The BigDate constructor stores the date both in ordinal and Gregorian forms internally. If you store one, it creates the other. <p/> The standard Sun Date won't handle dates prior to 1970 among other problems. BigDate handles dates 999,999 BC Jan 1 to 999,999 AD Dec 31, 0 = 1970 Jan 1. <p/> Are the following quirks of the calendar considered in this code? <p/> 1900 is not a leap year (mod 100): <b>yes</b>. <p/> 2000 is a leap year (mod 400): <b>yes</b>. <p/> The 10 missing days in 1582 October.: <b>yes</b> (Pope Gregory's correction) 1582 Oct 5 to 1582 Oct 14 never happened. <p/> Britain and its territories (including the USA and Canada) adopted the Gregorian correction in 1752: <b>Yes</b>. By then, 11 days had to be dropped. 1752 September 3 to 1752 September 13 never happened. However, you can modify constants in BigDate to use the British calendar. Such a change only affects dates prior to 1753 since BigDate calendar is based on Jan 1, 1970. toOrdinal with the Gregorian and British scheme will give the same number for recent dates. <b>You must recompile BigDate with the <b>isBritish</b> boolean changed to true.</b>. It was used by Britain and its colonies which later became the USA and Canada. However Nova Scotia used Pope Gregory's calendar. see http://mindprod.com/jgloss/missingdays.html PLEASE CONFIGURE isBritish AND RECOMPILE BIGDATE IF YOU WISH TO USE THE BRITISH CALENDAR. <p/> missing year 0 between 1 BC and 1 AD. <b>yes</b>. <p/> in Roman times leap years occurred at irregular intervals, Considered inauspicious, they were avoided during war. <b>no</b>. Instead we presume leap years every 4 years even back to 999,999BC. <p/> leap seconds: <b>no</b> <p/> Normally all you need is one BigDate object that you use for all interconversions with set(ordinal), set(yyy,mm,dd) and getOrdinal(), getYYYY(), getMM(), getDD(). <p/> java.util.Date has some odd habits, using 101 to represent the year 2001, and 11 to represent December. BigDate is more conventional. You use 2001 to represent the year 2001 and 12 to represent December. <p/> BigDate implements proleptic Gregorian and Julian calendars. That is, dates are computed by extrapolating the current rules indefinitely far backward and forward in time. As a result, BigDate may be used for all years to generate meaningful and consistent results. However, dates obtained using BigDate are historically accurate only from March 1, 4 AD onward, when modern Julian calendar rules were adopted. Before this date, leap year rules were applied irregularly, and before 45 BC the Julian calendar did not even exist. Prior to the institution of the Gregorian calendar, New Year's Day was March 25. To avoid confusion, this calendar always uses January 1. <p/> TODO Future enhancements: - handle time, and timezones, interconversion with GregorianCalendar dates.
<P>
<P>
<DL>
<DT><B>Version:</B></DT>
<DD>5.0 2007-10-15 new methods, nearestXXXDay, dayOfWeek, calendarDayOfWeek. <p/></DD>
<DT><B>Author:</B></DT>
<DD>Roedy Green, Canadian Mind Products</DD>
<DT><B>See Also:</B><DD><A HREF="../../../serialized-form.html#com.mindprod.common11.BigDate">Serialized Form</A></DL>
<HR>
<P>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#APR">APR</A></B></CODE>
<BR>
April is 4</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#APRIL">APRIL</A></B></CODE>
<BR>
April is 4</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#AUG">AUG</A></B></CODE>
<BR>
August is 8</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#AUGUST">AUGUST</A></B></CODE>
<BR>
August is 8</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#BYPASSCHECK">BYPASSCHECK</A></B></CODE>
<BR>
Constant: when passed to a constructor, it means caller guarantees YYYY MM DD are valid including leap year effects and missing day effects.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#CHECK">CHECK</A></B></CODE>
<BR>
constant: when passed to a contructor it means BigDate should check that YYYY MM DD are valid.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#dd">dd</A></B></CODE>
<BR>
Day, 1 to 31.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#DEC">DEC</A></B></CODE>
<BR>
December is 12</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#DECEMBER">DECEMBER</A></B></CODE>
<BR>
December is 12</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#FEB">FEB</A></B></CODE>
<BR>
February is 2</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#FEBRUARY">FEBRUARY</A></B></CODE>
<BR>
February is</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#FRI">FRI</A></B></CODE>
<BR>
Friday in Bigdate is 5</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#FRIDAY">FRIDAY</A></B></CODE>
<BR>
Friday in Bigdate is 5</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#isBritish">isBritish</A></B></CODE>
<BR>
PLEASE CONFIGURE isBritish BEFORE COMPILING.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#JAN">JAN</A></B></CODE>
<BR>
January is 1</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#JANUARY">JANUARY</A></B></CODE>
<BR>
January is 1</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/mindprod/common11/BigDate.html#JUL">JUL</A></B></CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -