xbn.util
Class UtilDate

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.util.UtilDate

public class UtilDate
extends XBNObject

Random functions for analyzing and manipulating java.util.Dates. See java.util.Date.

Source code:  UtilDate.java.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
UtilDate()
          Create a UtilDate.
 
Method Summary
 Date getDateXAgo(long l_multiplier, int i_unitsAgo, Date d_from)
          Get a Date that is X units before the provided date.
 Date getDateXAgoDays(int i_unitsAgo, Date d_from)
          Get a Date that is X days before the provided date.
 Date getDateXAgoHours(int i_unitsAgo, Date d_from)
          Get a Date that is X hours before the provided date.
 Date getDateXAgoMinutes(int i_unitsAgo, Date d_from)
          Get a Date that is X minutes before the provided date.
 Date getDateXAgoSeconds(int i_unitsAgo, Date d_from)
          Get a Date that is X seconds before the provided date.
 Date getDateXAgoWeeks(int i_unitsAgo, Date d_from)
          Get a Date that is X weeks before the provided date.
 Date getDateXBeforeNow(long l_multiplier, int i_unitsAgo)
          Get a Date that is X units before now.
 Date getDateXBNDays(int i_unitsAgo)
          Get a Date that is X days before now.
 Date getDateXBNHours(int i_unitsAgo)
          Get a Date that is X hours before now.
 Date getDateXBNMinutes(int i_unitsAgo)
          Get a Date that is X minutes before now.
 Date getDateXBNSeconds(int i_unitsAgo)
          Get a Date that is X seconds before now.
 Date getDateXBNWeeks(int i_unitsAgo)
          Get a Date that is X weeks before now.
static long getMillsInADay()
          How many milleseconds are there in a day?
static long getMillsInAMinute()
          How many milleseconds are there in a minute?
static long getMillsInAnHour()
          How many milleseconds are there in an hour?
static long getMillsInASecond()
          How many milleseconds are there in a second?
static long getMillsInAWeek()
          How many milleseconds are there in a week?
 int getNowMinusYDays(Date d_y)
          How many days before now is the provided date?
 int getNowMinusYHours(Date d_y)
          How many hours before now is the provided date?
 int getNowMinusYMinutes(Date d_y)
          How many minutes before now is the provided date?
 int getNowMinusYSeconds(Date d_y)
          How many seconds before now is the provided date?
 int getNowMinusYUnits(Date d_y, long l_multiplier)
          How many units before now is the provided date?
 int getNowMinusYWeeks(Date d_y)
          How many weeks before now is the provided date?
 int getXMinusYDays(Date d_x, Date d_y)
          How many days separate the provided dates?
 int getXMinusYHours(Date d_x, Date d_y)
          How many hours separate the provided dates?
 int getXMinusYMinutes(Date d_x, Date d_y)
          How many minutes separate the provided dates?
 int getXMinusYSeconds(Date d_x, Date d_y)
          How many seconds separate the provided dates?
 int getXMinusYUnits(Date d_x, Date d_y, long l_multiplier)
          How many units separate the provided dates?
 long getXMinusYUnitsLong(Date d_x, Date d_y, long l_multiplier)
          How many units, represented by a long, separate the provided dates?
 int getXMinusYWeeks(Date d_x, Date d_y)
          How many weeks separate the provided dates?
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilDate

public UtilDate()

Create a UtilDate. This constructor does nothing.

Method Detail

getDateXBNSeconds

public final Date getDateXBNSeconds(int i_unitsAgo)

Get a Date that is X seconds before now.

Returns:
getDateXBeforeNow(getMillsInASecond(), i_unitsAgo)

getDateXBNMinutes

public final Date getDateXBNMinutes(int i_unitsAgo)

Get a Date that is X minutes before now.

Returns:
getDateXBeforeNow(getMillsInAMinute(), i_unitsAgo)

getDateXBNHours

public final Date getDateXBNHours(int i_unitsAgo)

Get a Date that is X hours before now.

Returns:
getDateXBeforeNow(getMillsInAMinute(), i_unitsAgo)

getDateXBNDays

public final Date getDateXBNDays(int i_unitsAgo)

Get a Date that is X days before now.

Returns:
getDateXBeforeNow(getMillsInADay(), i_unitsAgo)

getDateXBNWeeks

public final Date getDateXBNWeeks(int i_unitsAgo)

Get a Date that is X weeks before now.

Returns:
getDateXBeforeNow(getMillsInAWeek(), i_unitsAgo)

getDateXBeforeNow

public final Date getDateXBeforeNow(long l_multiplier,
                                    int i_unitsAgo)

Get a Date that is X units before now.

Returns:
getDateXAgo(l_multiplier, i_unitsAgo, (new Date()))

getDateXAgoSeconds

public final Date getDateXAgoSeconds(int i_unitsAgo,
                                     Date d_from)

Get a Date that is X seconds before the provided date.

Returns:
getDateXAgo(getMillsInASecond(), i_unitsAgo, d_from)

getDateXAgoMinutes

public final Date getDateXAgoMinutes(int i_unitsAgo,
                                     Date d_from)

Get a Date that is X minutes before the provided date.

Returns:
getDateXAgo(getMillsInAMinute(), i_unitsAgo, d_from)

getDateXAgoHours

public final Date getDateXAgoHours(int i_unitsAgo,
                                   Date d_from)

Get a Date that is X hours before the provided date.

Returns:
getDateXAgo(getMillsInAMinute(), i_unitsAgo, d_from)

getDateXAgoDays

public final Date getDateXAgoDays(int i_unitsAgo,
                                  Date d_from)

Get a Date that is X days before the provided date.

Returns:
getDateXAgo(getMillsInADay(), i_unitsAgo, d_from)

getDateXAgoWeeks

public final Date getDateXAgoWeeks(int i_unitsAgo,
                                   Date d_from)

Get a Date that is X weeks before the provided date.

Returns:
getDateXAgo(getMillsInAWeek(), i_unitsAgo, d_from)

getDateXAgo

public final Date getDateXAgo(long l_multiplier,
                              int i_unitsAgo,
                              Date d_from)

Get a Date that is X units before the provided date.

Parameters:
l_multiplier - The number used to translate a Date's milleseconds to some other unit. May not be zero.
i_unitsAgo - The number of "units ago" you want the returned date to be, in relation to d_from.
d_from - The date that you want to count back from. May not be null.
Returns:
new Date(d_from.getTime() - (i_unitsAgo / l_multiplier))

getNowMinusYSeconds

public final int getNowMinusYSeconds(Date d_y)

How many seconds before now is the provided date?

Returns:
getNowMinusYUnits(d_y, getMillsInASecond())

getNowMinusYMinutes

public final int getNowMinusYMinutes(Date d_y)

How many minutes before now is the provided date?

Returns:
getNowMinusYUnits(d_y, getMillsInAMinute())

getNowMinusYHours

public final int getNowMinusYHours(Date d_y)

How many hours before now is the provided date?

Returns:
getNowMinusYUnits(d_y, getMillsInAnHour())

getNowMinusYDays

public final int getNowMinusYDays(Date d_y)

How many days before now is the provided date?

Returns:
getNowMinusYUnits(d_y, getMillsInADay())

getNowMinusYWeeks

public final int getNowMinusYWeeks(Date d_y)

How many weeks before now is the provided date?

Returns:
getNowMinusYUnits(d_y, getMillsInAWeek())

getNowMinusYUnits

public final int getNowMinusYUnits(Date d_y,
                                   long l_multiplier)

How many units before now is the provided date?

Returns:
getXMinusYUnits((new Date()), d_y, l_multiplier)

getXMinusYSeconds

public final int getXMinusYSeconds(Date d_x,
                                   Date d_y)

How many seconds separate the provided dates?

Returns:
getXMinusYUnits(d_x, d_y, getMillsInASecond())

getXMinusYMinutes

public final int getXMinusYMinutes(Date d_x,
                                   Date d_y)

How many minutes separate the provided dates?

Returns:
getXMinusYUnits(d_x, d_y, getMillsInAMinute())

getXMinusYHours

public final int getXMinusYHours(Date d_x,
                                 Date d_y)

How many hours separate the provided dates?

Returns:
getXMinusYUnits(d_x, d_y, getMillsInAnHour())

getXMinusYDays

public final int getXMinusYDays(Date d_x,
                                Date d_y)

How many days separate the provided dates?

Returns:
getXMinusYUnits(d_x, d_y, getMillsInADay())

getXMinusYWeeks

public final int getXMinusYWeeks(Date d_x,
                                 Date d_y)

How many weeks separate the provided dates?

Returns:
getXMinusYUnits(d_x, d_y, getMillsInAWeek())

getXMinusYUnits

public final int getXMinusYUnits(Date d_x,
                                 Date d_y,
                                 long l_multiplier)

How many units separate the provided dates?

Returns:
(new Long(d_x, d_y, l_multiplier)).intValue()

getXMinusYUnitsLong

public final long getXMinusYUnitsLong(Date d_x,
                                      Date d_y,
                                      long l_multiplier)

How many units, represented by a long, separate the provided dates?

Parameters:
d_x - The date on the left side of the minus equation. May not be null.
d_y - The date on the right side of the minus equation. May not be null.
l_multiplier - The number used to translate a Date's milleseconds to some other unit. May not be zero.
Returns:
(d_x.getTime() - d_y.getTime()) / l_multiplier)

getMillsInASecond

public static final long getMillsInASecond()

How many milleseconds are there in a second?

Returns:
1000

getMillsInAMinute

public static final long getMillsInAMinute()

How many milleseconds are there in a minute?

Returns:
60000 getMillsInASecond times sixty.

getMillsInAnHour

public static final long getMillsInAnHour()

How many milleseconds are there in an hour?

Returns:
360000 getMillsInAMinute times sixty

getMillsInADay

public static final long getMillsInADay()

How many milleseconds are there in a day?

Returns:
8640000 getMillsInAnHour times twenty four

getMillsInAWeek

public static final long getMillsInAWeek()

How many milleseconds are there in a week?

Returns:
60480000 getMillsInADay times seven



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo