vault backup: 2024-03-21 22:58:58

This commit is contained in:
2024-03-21 22:58:58 +00:00
parent 68fa81d02f
commit e241fe8bd6
49 changed files with 1950 additions and 210 deletions

View File

@@ -0,0 +1,379 @@
<!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.8.0_402) on Thu Mar 21 22:06:18 GMT 2024 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
DateUtil
</TITLE>
<META NAME="date" CONTENT="2024-03-21">
<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="DateUtil";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
Class DateUtil</H2>
<PRE>
java.lang.Object
<IMG SRC="./resources/inherit.gif" ALT="extended by "><B>DateUtil</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>DateUtil</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
A class DateUtil with the following methods for dealing with dates.
public static String convertDateToLongString(Date date)
public static String convertDateToShortString(Date date)
public static Date convertStringToDate(String dateString)
public static int daysBetween(Date startDate, Date endDate)
public static Date incrementDate(Date date, int noOfDays)
public static boolean isLeapYear(int year)
public static boolean isValidDateString(String dateString)
public static Date nextDate(Date date)
<P>
<P>
<DL>
<DT><B>Author:</B></DT>
<DD>D E Newton</DD>
</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&nbsp;java.text.SimpleDateFormat</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#dateFormatter">dateFormatter</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_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>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="DateUtil.html#DateUtil()">DateUtil</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_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>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#convertDateToLongString(java.util.Date)">convertDateToLongString</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts a Date object to a corresponding String in
the long date pattern style "Saturday, 25 March 2023".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#convertDateToShortString(java.util.Date)">convertDateToShortString</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts a Date object to a corresponding String in
the short date pattern style "25-03-2023".</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.util.Date</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#convertStringToDate(java.lang.String)">convertStringToDate</A></B>(java.lang.String&nbsp;dateString)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts a string in the short date pattern style "25-03-2023"
to a corresponding Date object.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#daysBetween(java.util.Date, java.util.Date)">daysBetween</A></B>(java.util.Date&nbsp;startDate,
java.util.Date&nbsp;endDate)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Calculates the number of days between two given dates, startDate and endDate.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.util.Date</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#incrementDate(java.util.Date, int)">incrementDate</A></B>(java.util.Date&nbsp;date,
int&nbsp;noOfDays)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Given date, a Date object, and noOfDays, an int, the method returns
a Date object corresponding to noOfDays later than date.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#isLeapYear(int)">isLeapYear</A></B>(int&nbsp;year)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Given year, an int, the method checks to see if the year
is a leap year.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#isValidDateString(java.lang.String)">isValidDateString</A></B>(java.lang.String&nbsp;dateString)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Given dateString, a String, the method checks to see if string
corresponds to a valid shortDatePattern.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.util.Date</CODE></FONT></TD>
<TD><CODE><B><A HREF="DateUtil.html#nextDate(java.util.Date)">nextDate</A></B>(java.util.Date&nbsp;date)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Given date, a Date object, the method returns
a Date object corresponding to the next day.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="dateFormatter"><!-- --></A><H3>
dateFormatter</H3>
<PRE>
public static java.text.SimpleDateFormat <B>dateFormatter</B></PRE>
<DL>
<DL>
</DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="DateUtil()"><!-- --></A><H3>
DateUtil</H3>
<PRE>
public <B>DateUtil</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="convertDateToLongString(java.util.Date)"><!-- --></A><H3>
convertDateToLongString</H3>
<PRE>
public static java.lang.String <B>convertDateToLongString</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Converts a Date object to a corresponding String in
the long date pattern style "Saturday, 25 March 2023".
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - a Date object
<DT><B>Returns:</B><DD>a String, containing a long date pattern</DL>
</DD>
</DL>
<HR>
<A NAME="convertDateToShortString(java.util.Date)"><!-- --></A><H3>
convertDateToShortString</H3>
<PRE>
public static java.lang.String <B>convertDateToShortString</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Converts a Date object to a corresponding String in
the short date pattern style "25-03-2023".
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - a Date object
<DT><B>Returns:</B><DD>a String, containing a short date pattern</DL>
</DD>
</DL>
<HR>
<A NAME="convertStringToDate(java.lang.String)"><!-- --></A><H3>
convertStringToDate</H3>
<PRE>
public static java.util.Date <B>convertStringToDate</B>(java.lang.String&nbsp;dateString)</PRE>
<DL>
<DD>Converts a string in the short date pattern style "25-03-2023"
to a corresponding Date object.
Any leading or trailing spaces are first removed from the date string.
The String parameter that represent a date as a string must be in the
format dd-mm-yyy (e.g. 25-03-2023 or 25-3-2023) where dd represents
one or two digits representing the day in the month, similarly for
mm representing the month in the year and yyyy represents the four
digits for the year.
A RuntimeException is thrown if the date string is not recognised as
a valid date. Such exceptions do not need to be caught or thrown as
they are unchecked exceptions, but can be caught if necessary.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>dateString</CODE> - a Date object
<DT><B>Returns:</B><DD>the Date object</DL>
</DD>
</DL>
<HR>
<A NAME="daysBetween(java.util.Date, java.util.Date)"><!-- --></A><H3>
daysBetween</H3>
<PRE>
public static int <B>daysBetween</B>(java.util.Date&nbsp;startDate,
java.util.Date&nbsp;endDate)</PRE>
<DL>
<DD>Calculates the number of days between two given dates, startDate and endDate.
If startDate is after endDate then the number of days returned will be negative.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>startDate</CODE> - a Date object<DD><CODE>endDate</CODE> - a Date object
<DT><B>Returns:</B><DD>an int, number of days between the dates</DL>
</DD>
</DL>
<HR>
<A NAME="incrementDate(java.util.Date, int)"><!-- --></A><H3>
incrementDate</H3>
<PRE>
public static java.util.Date <B>incrementDate</B>(java.util.Date&nbsp;date,
int&nbsp;noOfDays)</PRE>
<DL>
<DD>Given date, a Date object, and noOfDays, an int, the method returns
a Date object corresponding to noOfDays later than date.
If noOfDays is negative, the resulting Date object will be before date.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>date</CODE> - a Date object<DD><CODE>noOfDays</CODE> - an int
<DT><B>Returns:</B><DD>a Date</DL>
</DD>
</DL>
<HR>
<A NAME="isLeapYear(int)"><!-- --></A><H3>
isLeapYear</H3>
<PRE>
public static boolean <B>isLeapYear</B>(int&nbsp;year)</PRE>
<DL>
<DD>Given year, an int, the method checks to see if the year
is a leap year.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>year,</CODE> - an int
<DT><B>Returns:</B><DD>a boolean, true only if the year is a leap year.</DL>
</DD>
</DL>
<HR>
<A NAME="isValidDateString(java.lang.String)"><!-- --></A><H3>
isValidDateString</H3>
<PRE>
public static boolean <B>isValidDateString</B>(java.lang.String&nbsp;dateString)</PRE>
<DL>
<DD>Given dateString, a String, the method checks to see if string
corresponds to a valid shortDatePattern.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>dateString,</CODE> - a String
<DT><B>Returns:</B><DD>a boolean, true only if the dateString is a valid pattern</DL>
</DD>
</DL>
<HR>
<A NAME="nextDate(java.util.Date)"><!-- --></A><H3>
nextDate</H3>
<PRE>
public static java.util.Date <B>nextDate</B>(java.util.Date&nbsp;date)</PRE>
<DL>
<DD>Given date, a Date object, the method returns
a Date object corresponding to the next day.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>noOfDays</CODE> - an int
<DT><B>Returns:</B><DD>a Date</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<HR>
</BODY>
</HTML>