atg.core.util
Class DateDoodads

java.lang.Object
  extended by atg.core.util.DateDoodads
Direct Known Subclasses:
GiftlistDateUtil

public class DateDoodads
extends java.lang.Object

Extra stuff for dealing with dates


Field Summary
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 Summary
DateDoodads()
           
 
Method Summary
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]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


kMonths

public static final java.lang.String[] kMonths

kMonthsLower

public static final java.lang.String[] kMonthsLower

kMonthsAbbrev

public static final java.lang.String[] kMonthsAbbrev

kMonthsAbbrevLower

public static final java.lang.String[] kMonthsAbbrevLower

kMonthNumbers

public static final java.lang.String[] kMonthNumbers

kLastDates

public static final int[] kLastDates

kDays

public static final java.lang.String[] kDays

kDaysAbbrev

public static final java.lang.String[] kDaysAbbrev

SECOND_MILLIS

public static final long SECOND_MILLIS
See Also:
Constant Field Values

MINUTE_MILLIS

public static final long MINUTE_MILLIS
See Also:
Constant Field Values

HOUR_MILLIS

public static final long HOUR_MILLIS
See Also:
Constant Field Values

DAY_MILLIS

public static final long DAY_MILLIS
See Also:
Constant Field Values

WEEK_MILLIS

public static final long WEEK_MILLIS
See Also:
Constant Field Values

YEAR_MILLIS

public static final long YEAR_MILLIS
See Also:
Constant Field Values

SPACE_FORMATTER_STRING

public static final java.lang.String SPACE_FORMATTER_STRING
See Also:
Constant Field Values

DASH_FORMATTER_STRING

public static final java.lang.String DASH_FORMATTER_STRING
See Also:
Constant Field Values

DASH_CHAR

public static final char DASH_CHAR
See Also:
Constant Field Values

TIMEZONE_STRING

public static final java.lang.String TIMEZONE_STRING
See Also:
Constant Field Values

GMT_TIMEZONE

public static final java.util.TimeZone GMT_TIMEZONE
Constructor Detail

DateDoodads

public DateDoodads()
Method Detail

lastDate

public static int lastDate(int iMonth,
                           int iYear)
Returns the last date of a given month (accounting for leap year)

Parameters:
iMonth - Month (0 - 11) as in java.util.Date
iYear - Year after 1900 as in java.util.Date
See Also:
Date

isLeapYear

public static boolean isLeapYear(int iYear)
Returns true if year is a leap year, according to the Gregorian Calendar.

Parameters:
iYear - Year after 1900 as in java.util.Date
See Also:
Date

monthString

public static java.lang.String monthString(int iMonth)
Returns the full month (English)

Parameters:
iMonth - Month 0-11 as in java.util.Date
See Also:
Date

monthStringAbbrev

public static java.lang.String monthStringAbbrev(int iMonth)
Returns the 3 letter appreviated month (English)

Parameters:
iMonth - Month 0-11 as in java.util.Date
See Also:
Date

dayString

public static java.lang.String dayString(int iDay)
Returns the full day (English)

Parameters:
iDay - Day 0-6 as in java.util.Date
See Also:
Date

dayStringAbbrev

public static java.lang.String dayStringAbbrev(int iDay)
Returns the 3 letter abbreviated day (English)

Parameters:
iDay - Day 0-6 as in java.util.Date
See Also:
Date

dateString

public 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


dateStringFourDigitYear

public 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. This is done by adding 1900 to the year returned by Date.


timeString

public static java.lang.String timeString(java.util.Date iDate)
Formats the time of a date in 12-hour format, as HH:MM[am/pm]


approxIntervalString

public 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.


stringDate

public static java.util.Date stringDate(java.lang.String iDate)
                                 throws java.lang.IllegalArgumentException
This converts a string to a date. If the string is m/d/y input, it corrects the month.

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.

Throws:
java.lang.IllegalArgumentException

setThrowTwoDigitYearException

public static void setThrowTwoDigitYearException(boolean pThrowException)
Call this method with a flag to turn off the throwing of the 2 digit year exception.


setTwoDigitWrapYear

public static void setTwoDigitWrapYear(int pYear)
Call this method to set the year from which we wrap two digit years.


internetTimeString

public 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

Parameters:
pDate - a java.util.Date
See Also:
Date

dateTimeString

public static java.lang.String dateTimeString(java.util.Date pDate)
Formats a date in a fashion that can be reconverted by stringDate()


httpDateString

public static java.lang.String httpDateString(long pTime)
These are the new httpDateString routines that work much better in March


httpDateString

public static java.lang.String httpDateString(long pTime,
                                              char pDateSep)

httpDateStringOld

public 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. See Bug# 70307


httpDateStringOld

public static java.lang.String httpDateStringOld(long pTime,
                                                 char pDateSep)

sameDay

public static boolean sameDay(java.util.Date pDate1,
                              java.util.Date pDate2)
Returns true if two dates match, ignoring time of day.


sameWeek

public static boolean sameWeek(java.util.Date pDate1,
                               java.util.Date pDate2)
Returns true if two dates occur during the same calendar week (i.e. the same Sun-to-Mon interval)


dateFromDay

public java.util.Date dateFromDay(int iDays,
                                  int iYear)
Returns a date that is iDays into iYear. Specify a base year and any number of days, and get back a Date that many days away from Jan. 1 of the base year. Use to work around java.util.Data bug that produces wrong dates if the specified number of days is >=128 in any Date(int, int, int [...]) constructor.

Parameters:
iDays - Days (0 - 731)
iYear - Year after 1900 as in java.util.Date

padString

public static java.lang.String padString(java.lang.String pThing,
                                         int pWidth,
                                         char pPad)

main

public static void main(java.lang.String[] args)