public class DateDoodads
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
static char |
DASH_CHAR |
static java.lang.String |
DASH_FORMATTER_STRING |
static long |
DAY_MILLIS |
static java.util.TimeZone |
GMT_TIMEZONE |
static long |
HOUR_MILLIS |
static java.lang.String[] |
kDays |
static java.lang.String[] |
kDaysAbbrev |
static int[] |
kLastDates |
static java.lang.String[] |
kMonthNumbers |
static java.lang.String[] |
kMonths |
static java.lang.String[] |
kMonthsAbbrev |
static java.lang.String[] |
kMonthsAbbrevLower |
static java.lang.String[] |
kMonthsLower |
static long |
MINUTE_MILLIS |
static long |
SECOND_MILLIS |
static java.lang.String |
SPACE_FORMATTER_STRING |
static java.lang.String |
TIMEZONE_STRING |
static long |
WEEK_MILLIS |
static long |
YEAR_MILLIS |
Constructor and Description |
---|
DateDoodads() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
approxIntervalString(java.util.Date startDate,
java.util.Date endDate)
Formats the interval between two dates as a text string expressing
the length of time, approximately.
|
java.util.Date |
dateFromDay(int iDays,
int iYear)
Returns a date that is iDays into iYear.
|
static java.lang.String |
dateString(java.util.Date date)
This formats the date the way we want it - m/d/y
It adds one to the month to correct Date's month range of 0-11
|
static java.lang.String |
dateStringFourDigitYear(java.util.Date date)
This formats the date the way we want it - m/d/y
It adds one to the month to correct Date's month range of 0-11
This method prints a four digit year.
|
static java.lang.String |
dateTimeString(java.util.Date pDate)
Formats a date in a fashion that can be reconverted by stringDate()
|
static java.lang.String |
dayString(int iDay)
Returns the full day (English)
|
static java.lang.String |
dayStringAbbrev(int iDay)
Returns the 3 letter abbreviated day (English)
|
static java.lang.String |
httpDateString(long pTime)
These are the new httpDateString routines that work much better
in March
|
static java.lang.String |
httpDateString(long pTime,
char pDateSep) |
static java.lang.String |
httpDateStringOld(long pTime)
These are the old routines, they don't work very well in March
Note: these routines are no longer used, but I kept them here
just in case someone needed them.
|
static java.lang.String |
httpDateStringOld(long pTime,
char pDateSep) |
static java.lang.String |
internetTimeString(java.util.Date pDate)
Formats a date as in RFC 850, 1036 & 822
Note that the year only has 2 digits!!!! So I guess the internet will be over at midnight |
static boolean |
isLeapYear(int iYear)
Returns true if year is a leap year, according to the
Gregorian Calendar.
|
static int |
lastDate(int iMonth,
int iYear)
Returns the last date of a given month (accounting for leap year)
|
static void |
main(java.lang.String[] args) |
static java.lang.String |
monthString(int iMonth)
Returns the full month (English)
|
static java.lang.String |
monthStringAbbrev(int iMonth)
Returns the 3 letter appreviated month (English)
|
static java.lang.String |
padString(java.lang.String pThing,
int pWidth,
char pPad) |
static boolean |
sameDay(java.util.Date pDate1,
java.util.Date pDate2)
Returns true if two dates match, ignoring time of day.
|
static boolean |
sameWeek(java.util.Date pDate1,
java.util.Date pDate2)
Returns true if two dates occur during the same calendar week
(i.e.
|
static void |
setThrowTwoDigitYearException(boolean pThrowException)
Call this method with a flag to turn off the throwing of the 2 digit
year exception.
|
static void |
setTwoDigitWrapYear(int pYear)
Call this method to set the year from which we wrap two digit years.
|
static java.util.Date |
stringDate(java.lang.String iDate)
This converts a string to a date.
|
static java.lang.String |
timeString(java.util.Date iDate)
Formats the time of a date in 12-hour format, as HH:MM[am/pm]
|
public static java.lang.String CLASS_VERSION
public static final java.lang.String[] kMonths
public static final java.lang.String[] kMonthsLower
public static final java.lang.String[] kMonthsAbbrev
public static final java.lang.String[] kMonthsAbbrevLower
public static final java.lang.String[] kMonthNumbers
public static final int[] kLastDates
public static final java.lang.String[] kDays
public static final java.lang.String[] kDaysAbbrev
public static final long SECOND_MILLIS
public static final long MINUTE_MILLIS
public static final long HOUR_MILLIS
public static final long DAY_MILLIS
public static final long WEEK_MILLIS
public static final long YEAR_MILLIS
public static final java.lang.String SPACE_FORMATTER_STRING
public static final java.lang.String DASH_FORMATTER_STRING
public static final char DASH_CHAR
public static final java.lang.String TIMEZONE_STRING
public static final java.util.TimeZone GMT_TIMEZONE
public static int lastDate(int iMonth, int iYear)
iMonth
- Month (0 - 11) as in java.util.DateiYear
- Year after 1900 as in java.util.DateDate
public static boolean isLeapYear(int iYear)
iYear
- Year after 1900 as in java.util.DateDate
public static java.lang.String monthString(int iMonth)
iMonth
- Month 0-11 as in java.util.DateDate
public static java.lang.String monthStringAbbrev(int iMonth)
iMonth
- Month 0-11 as in java.util.DateDate
public static java.lang.String dayString(int iDay)
iDay
- Day 0-6 as in java.util.DateDate
public static java.lang.String dayStringAbbrev(int iDay)
iDay
- Day 0-6 as in java.util.DateDate
public static java.lang.String dateString(java.util.Date date)
public static java.lang.String dateStringFourDigitYear(java.util.Date date)
public static java.lang.String timeString(java.util.Date iDate)
public static java.lang.String approxIntervalString(java.util.Date startDate, java.util.Date endDate)
public static java.util.Date stringDate(java.lang.String iDate) throws java.lang.IllegalArgumentException
WARNING : Two digit years are no longer supported by defualt. We strongly recommend that you do not use 2 digit years. If you do pass in a 2 digit year then a TwoDigitYearException will be thrown, containing the date calculated by the following heuristic:
Two digit dates before 1970 in m/d/y will be translated to 20xx!!!!!!
We also look for the year. If the year is less than 70, we assume that it is for the next century as in 2005. We add 100 to correct the year in Date since it is measured from 1900.
java.lang.IllegalArgumentException
public static void setThrowTwoDigitYearException(boolean pThrowException)
public static void setTwoDigitWrapYear(int pYear)
public static java.lang.String internetTimeString(java.util.Date pDate)
pDate
- a java.util.DateDate
public static java.lang.String dateTimeString(java.util.Date pDate)
public static java.lang.String httpDateString(long pTime)
public static java.lang.String httpDateString(long pTime, char pDateSep)
public static java.lang.String httpDateStringOld(long pTime)
public static java.lang.String httpDateStringOld(long pTime, char pDateSep)
public static boolean sameDay(java.util.Date pDate1, java.util.Date pDate2)
public static boolean sameWeek(java.util.Date pDate1, java.util.Date pDate2)
public java.util.Date dateFromDay(int iDays, int iYear)
iDays
- Days (0 - 731)iYear
- Year after 1900 as in java.util.Datepublic static java.lang.String padString(java.lang.String pThing, int pWidth, char pPad)
public static void main(java.lang.String[] args)