com.quadrique.jbuildingblocks.core.time
Class JbbDate

java.lang.Object
  extended by com.quadrique.jbuildingblocks.core.time.JbbDate
All Implemented Interfaces:
Serializable, Comparable<JbbDate>

public class JbbDate
extends Object
implements Serializable, Comparable<JbbDate>

This class provides convenience routines for date and time manipulation:

See Also:
Serialized Form

Method Summary
 int compareTo(Date date)
          convenience method to compare a JbbDate instance with a Date instance
 int compareTo(JbbDate date)
          convenience method to compare 2 JbbDate instance
 String formatDate()
          the formatting is based on the current locale
 String formatDate(String format)
           
 String formatDateFull()
           
 String formatDateLong()
           
 String formatDateMedium()
           
 String formatDateShort()
          format the date as a string in short format (SHORT is completely numeric, such as 12.13.52 or 3:30pm).
 String formatDateTime()
          format the date as a string in the default format for the current locale the formatting is based on the current locale
 String formatDateTime(String format)
           
 String formatDateTimeFull()
          format the date as a string in short format (FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST).
 String formatDateTimeLong()
          format the date as a string in short format (LONG is longer, such as January 12, 1952 or 3:30:32pm).
 String formatDateTimeMedium()
          format the date as a string in short format (MEDIUM is longer, such as Jan 12, 1952 ).
 String formatDateTimeRfc822()
          The RFC 2822 date and timeis described as: // rfc1123-date = wkday "," SP date1 SP time SP "GMT" // date1 = 2DIGIT SP month SP 4DIGIT // ; day month year (e.g., 02 Jun 1982) // time = 2DIGIT ":" 2DIGIT ":" 2DIGIT // ; 00:00:00 - 23:59:59 // wkday = "Mon" | "Tue" | "Wed" // | "Thu" | "Fri" | "Sat" | "Sun" // month = "Jan" | "Feb" | "Mar" | "Apr" // | "May" | "Jun" | "Jul" | "Aug" // | "Sep" | "Oct" | "Nov" | "Dec"
Sample: "Mon, 26 Feb 2007 21:23:14 +0100"
 String formatDateTimeShort()
          format the date as a string in short format (SHORT is completely numeric, such as 12.13.52 or 3:30pm).
 String formatDateTimeXsd()
          The xsd:dateTime format is described in chapter 4 of ISO 8601 and the W3C consortium (http://www.w3.org/TR/NOTE-datetime )
In a nutshell, the format is:
YYYY-MM-DDThh:mm:ss.SSS[Z|(+|-)hh:mm]
The time zone may be specified as Z (UTC) or (+|-)hh:mm.
 String formatDateXsd()
           
 String formatTime()
          format the date as a string in the default format for the current locale the formatting is based on the current locale
 String formatTimeFull()
          format the date as a string in short format (FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST).
 String formatTimeLong()
          format the date as a string in short format (LONG is longer, such as January 12, 1952 or 3:30:32pm).
 String formatTimeMedium()
          format the date as a string in short format (MEDIUM is longer, such as Jan 12, 1952 ).
 String formatTimeShort()
          format the date as a string in short format (SHORT is completely numeric, such as 12.13.52 or 3:30pm).
 JbbDate getBeginningOfDay()
           
 JbbDate getBeginningOfMonth()
           
 JbbDate getBeginningOfMonth(int month)
           
 JbbDate getBeginningOfQuarter()
           
 JbbDate getBeginningOfQuarter(int quarterNumber)
           
 JbbDate getBeginningOfWeek()
           
 JbbDate getBeginningOfWeek(int weekNumber)
           
 JbbDate getBeginningOfYear()
           
 Calendar getCalendar()
           
 Date getDate()
           
 int getDayOfMonth()
           
 int getDayOfWeek()
           
 int getDayOfYear()
           
 JbbDateDifference getDifference(Date dateToCompare)
           
 JbbDate getEndOfDay()
           
 JbbDate getEndOfMonth()
           
 JbbDate getEndOfMonth(int month)
           
 JbbDate getEndOfQuarter()
           
 JbbDate getEndOfQuarter(int quarterNumber)
           
 JbbDate getEndOfWeek()
           
 JbbDate getEndOfWeek(int weekNumber)
           
 JbbDate getEndOfYear()
           
 int getHour()
           
 JbbDateIntervalsDate getIntervals(boolean doNotExtend)
           
 JbbDateIntervalsYear getIntervalsForEntireYear()
           
 Locale getLocale()
           
 int getMilliSecond()
           
 int getMinute()
           
 int getMonth()
           
 JbbDate getMonth(int month)
           
 int getNbOfDaysBetweenDates()
           
 int getNbOfDaysBetweenDates(Date inputDate)
           
 long getNbOfHoursBetweenDates()
           
 long getNbOfHoursBetweenDates(Date inputDate)
           
 long getNbOfMiliisecondsBetweenDates()
           
 long getNbOfMillisecondsBetweenDates(Date inputDate)
           
 long getNbOfMinutesBetweenDates()
           
 long getNbOfMinutesBetweenDates(Date inputDate)
           
 long getNbOfSecondsBetweenDates()
           
 long getNbOfSecondsBetweenDates(Date inputDate)
           
 int getNbOfYearsBetweenDates()
           
 int getNbOfYearsBetweenDates(Date inputDate)
           
 JbbDate getNextBusinessDay()
           
 JbbDate getNextDay()
           
 JbbDate getNextMonth()
           
 JbbDate getNextNBusinessDay(int nbOfBusinessDays)
           
 JbbDate getNextNDay(int numberOfDaysToAdd)
           
 JbbDate getNextNMonth(int nbMonths)
           
 JbbDate getNextNWeek(int nbWeeks)
           
 JbbDate getNextNYears(int nbYears)
           
 JbbDate getNextWeek()
           
 JbbDate getNextYear()
           
 JbbDate getNthDayOfMonth(int dayNumber)
           
 JbbDate getNthDayOfWeek(int dayNumber)
           
 JbbDate getNthDayOfWeek(int weekNumber, int dayNumber)
           
 JbbDate getNthDayOfWeekOnOrAfter(int dayOfTheWeek, int hour, int minute, int second, int millisecond)
           
 JbbDate getNthDayOfYear(int dayNumber)
           
 JbbDate getPreviousBusinessDay()
           
 JbbDate getPreviousDay()
           
 JbbDate getPreviousMonth()
           
 JbbDate getPreviousNBusinessDay(int nbOfBusinessDays)
           
 JbbDate getPreviousNDay(int nbDays)
           
 JbbDate getPreviousNMonth(int nbMonth)
           
 JbbDate getPreviousNWeek(int nbWeeks)
           
 JbbDate getPreviousNYear(int nbYears)
           
 JbbDate getPreviousWeek()
           
 JbbDate getPreviousYear()
           
 int getQuarter()
           
 JbbDate getSameDayWithDifferentTime(int hour, int minute, int second, int millisecond)
           
 int getSecond()
           
 TimeZone getTimeZone()
           
 int getWeek()
           
 int getYear()
           
 JbbDate getYear(int year)
           
 boolean isBusinessDay()
           
 boolean isDateAfterDate2AndBeforeDate3(Date d2, Date d3)
           
 boolean isDateAfterDate2MinusNDays(Date d2, int nbDays)
           
 boolean isDateAfterDate2MinusNDaysAndBeforeDate2PlusNDays(Date d2, int nbDays)
           
 boolean isDateAfterDate2PlusNDays(Date d2, int nbDays)
           
 boolean isDateBeforeDate2MinusNDays(Date d2, int nbDays)
           
 boolean isDateBeforeDate2PlusNDays(Date d2, int nbDays)
           
 boolean isSameDay(Date inputDate)
           
static JbbDate newInstance()
          factory method
static JbbDate newInstance(Date date)
          Factory method
static JbbDate newInstance(Date date, Locale locale)
          Factory method
static JbbDate newInstance(Date date, Locale locale, TimeZone timeZone)
          Factory method
static JbbDate newInstance(int year, int month, int day)
           
static JbbDate newInstance(int year, int month, int day, int hour, int minute, int second, int millisecond)
           
static JbbDate newInstance(int year, int month, int day, int hour, int minute, int second, int millisecond, Locale locale)
           
static JbbDate newInstance(int year, int month, int day, int hour, int minute, int second, int milliseconds, Locale locale, TimeZone timeZone)
           
static JbbDate newInstance(int year, int month, int day, Locale locale)
           
static JbbDate newInstance(int year, int month, int day, Locale locale, TimeZone timeZone)
           
static JbbDate newInstance(Locale locale)
          factory method
static JbbDate newInstance(Locale locale, TimeZone timeZone)
          factory method
static JbbDate newInstance(long date)
          Factory method
static JbbDate newInstance(long date, Locale locale)
          Factory method
static JbbDate newInstance(long date, Locale locale, TimeZone timeZone)
          Factory method
static JbbDate newInstanceFromRfc822String(String xsdDateTime)
           
static JbbDate newInstanceFromRfc822String(String xsdDateTime, Locale locale)
           
static JbbDate newInstanceFromRfc822String(String xsdDateTime, Locale locale, TimeZone timeZone)
           
static JbbDate newInstanceFromXsdString(String xsdDateTime)
           
static JbbDate newInstanceFromXsdString(String xsdDateTime, Locale locale)
           
static JbbDate newInstanceFromXsdString(String xsdDateTime, Locale locale, TimeZone timeZone)
           
 void setBeginningOfDay()
          calls the getBeginningOfDay() and changes the internal state to the return value.
 void setBeginningOfMonth()
          calls the getBeginningOfMonth() and changes the internal state to the return value.
 void setBeginningOfMonth(int month)
          calls the getBeginningOfMonth(int month) and changes the internal state to the return value.
 void setBeginningOfQuarter()
          calls the getBeginningOfQuarter() and changes the internal state to the return value.
 void setBeginningOfQuarter(int quarterNumber)
          calls the getBeginningOfQuarter(int quarterNumber) and changes the internal state to the return value.
 void setBeginningOfWeek()
          calls the getBeginningOfWeek() and changes the internal state to the return value.
 void setBeginningOfWeek(int weekNumber)
          calls the getBeginningOfWeek(weekNumber) and changes the internal state to the return value.
 void setBeginningOfYear()
          calls the getBeginningOfYear() and changes the internal state to the return value.
 void setEndOfDay()
          calls the getEndOfDay() and changes the internal state to the return value.
 void setEndOfMonth()
          calls the getEndOfMonth() and changes the internal state to the return value.
 void setEndOfMonth(int month)
          calls the getEndOfMonth(int month) and changes the internal state to the return value.
 void setEndOfQuarter()
          calls the getEndOfQuarter() and changes the internal state to the return value.
 void setEndOfQuarter(int quarterNumber)
          calls the getEndOfQuarter(int quarterNumber) and changes the internal state to the return value.
 void setEndOfWeek()
          calls the getEndOfWeek() and changes the internal state to the return value.
 void setEndOfWeek(int weekNumber)
          calls the getEndOfWeek(weekNumber) and changes the internal state to the return value.
 void setEndOfYear()
          calls the getEndOfYear() and changes the internal state to the return value.
 void setMonth(int month)
          calls the getMonth(month) and changes the internal state to the return value.
 void setNextBusinessDay()
          calls the getNextBusinessDay() and changes the internal state to the return value.
 void setNextDay()
          calls the getNextDay() and changes the internal state to the return value.
 void setNextMonth()
          calls the getNextMonth() and changes the internal state to the return value.
 void setNextNBusinessDay(int nbOfBusinessDays)
          calls the getNextNBusinessDay(nbOfBusinessDays) and changes the internal state to the return value.
 void setNextNDay(int numberOfDaysToAdd)
          calls the getNextNDay(numberOfDaysToAdd) and changes the internal state to the return value.
 void setNextNMonth(int nbMonths)
          calls the getNextNMonth(int nbMonths) and changes the internal state to the return value.
 void setNextNWeek(int nbWeeks)
          calls the getNextNWeek(nbWeeks) and changes the internal state to the return value.
 void setNextNYears(int nbYears)
          calls the getNextNYears(nbYears) and changes the internal state to the return value.
 void setNextWeek()
          calls the getNextWeek() and changes the internal state to the return value.
 void setNextYear()
          calls the getNextYear() and changes the internal state to the return value.
 void setNthDayOfMonth(int dayNumber)
          calls the getNthDayOfMonth(int dayNumber) and changes the internal state to the return value.
 void setNthDayOfWeek(int dayNumber)
          calls the getNthDayOfWeek(int dayNumber) and changes the internal state to the return value.
 void setNthDayOfWeek(int weekNumber, int dayNumber)
          calls the getNthDayOfWeek(int weekNumber, int dayNumber) and changes the internal state to the return value.
 void setNthDayOfWeekOnOrAfter(int dayOfTheWeek, int hour, int minute, int second, int millisecond)
          calls the getNthDayOfWeekOnOrAfter(int dayOfTheWeek, int hour, int minute, int second, int millisecond) and changes the internal state to the return value.
 void setNthDayOfYear(int dayNumber)
          calls the getNthDayOfYear(int dayNumber) and changes the internal state to the return value.
 void setPreviousBusinessDay()
          calls the getPreviousBusinessDay() and changes the internal state to the return value.
 void setPreviousDay()
          calls the getPreviousDay() and changes the internal state to the return value.
 void setPreviousMonth()
          calls the getPreviousMonth() and changes the internal state to the return value.
 void setPreviousNBusinessDay(int nbOfBusinessDays)
          calls the getPreviousNBusinessDay(nbOfBusinessDays) and changes the internal state to the return value.
 void setPreviousNDay(int nbDays)
          calls the getPreviousNDay() and changes the internal state to the return value.
 void setPreviousNMonth(int nbMonth)
          calls the getPreviousNMonth(int nbMonth) and changes the internal state to the return value.
 void setPreviousNWeek(int nbWeeks)
          calls the getPreviousNWeek(nbWeeks) and changes the internal state to the return value.
 void setPreviousNYear(int nbYears)
          calls the getPreviousNYear(int nbYears) and changes the internal state to the return value.
 void setPreviousWeek()
          calls the getPreviousWeek() and changes the internal state to the return value.
 void setPreviousYear()
          calls the getPreviousYear() and changes the internal state to the return value.
 void setSameDayWithDifferentTime(int hour, int minute, int second, int millisecond)
          calls the getSameDayWithDifferentTime(int hour, int minute, int second, int millisecond) and changes the internal state to the return value.
 void setYear(int year)
          calls the getYear(year) and changes the internal state to the return value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static JbbDate newInstance()
factory method


newInstance

public static JbbDate newInstance(Locale locale)
factory method

Parameters:
locale - the locale to use

newInstance

public static JbbDate newInstance(Locale locale,
                                  TimeZone timeZone)
factory method

Parameters:
timeZone - the timeZone to use

newInstance

public static JbbDate newInstance(Date date,
                                  Locale locale)
Factory method

Parameters:
date - the reference date to use
locale -
Returns:

newInstance

public static JbbDate newInstance(Date date,
                                  Locale locale,
                                  TimeZone timeZone)
Factory method

Parameters:
date - the reference date to use
locale -
Returns:

newInstance

public static JbbDate newInstance(Date date)
Factory method

Parameters:
date -
Returns:

newInstance

public static JbbDate newInstance(long date)
Factory method

Parameters:
date -
Returns:

newInstance

public static JbbDate newInstance(long date,
                                  Locale locale)
Factory method

Parameters:
date - The date expressed as a number of milliseconds since January 1,1970
locale -
Returns:

newInstance

public static JbbDate newInstance(long date,
                                  Locale locale,
                                  TimeZone timeZone)
Factory method

Parameters:
date - The date expressed as a number of milliseconds since January 1,1970
locale -
Returns:

newInstance

public static JbbDate newInstance(int year,
                                  int month,
                                  int day,
                                  int hour,
                                  int minute,
                                  int second,
                                  int milliseconds,
                                  Locale locale,
                                  TimeZone timeZone)
                           throws Exception
Parameters:
year - e.g. 2008
month - 0 - 11
day - 1 - ...
hour - 0 - 23
minute - 0 - 59
second - 0 - 59
milliseconds - 0- 999
locale -
Returns:
Throws:
Exception

newInstance

public static JbbDate newInstance(int year,
                                  int month,
                                  int day,
                                  Locale locale)
                           throws Exception
Parameters:
year - e.g. 2008
month - 0 - 11
day - 1 - ...
locale -
Returns:
Throws:
Exception

newInstance

public static JbbDate newInstance(int year,
                                  int month,
                                  int day,
                                  Locale locale,
                                  TimeZone timeZone)
                           throws Exception
Parameters:
year - e.g. 2008
month - 0 - 11
day - 1 - ...
locale -
Returns:
Throws:
Exception

newInstance

public static JbbDate newInstance(int year,
                                  int month,
                                  int day,
                                  int hour,
                                  int minute,
                                  int second,
                                  int millisecond)
                           throws Exception
Parameters:
year - e.g. 2008
month - 0 - 11
day - 1 - ...
hour - 0 - 23
minute - 0 - 59
second - 0 - 59
milliseconds - 0- 999
Returns:
Throws:
Exception

newInstance

public static JbbDate newInstance(int year,
                                  int month,
                                  int day,
                                  int hour,
                                  int minute,
                                  int second,
                                  int millisecond,
                                  Locale locale)
                           throws Exception
Parameters:
year - e.g. 2008
month - 0 - 11
day - 1 - ...
hour - 0 - 23
minute - 0 - 59
second - 0 - 59
milliseconds - 0- 999
Returns:
Throws:
Exception

newInstance

public static JbbDate newInstance(int year,
                                  int month,
                                  int day)
                           throws Exception
Parameters:
year - e.g. 2008
month - 0 - 11
day - 1 - ...
Returns:
Throws:
Exception

newInstanceFromXsdString

public static JbbDate newInstanceFromXsdString(String xsdDateTime,
                                               Locale locale,
                                               TimeZone timeZone)
                                        throws Exception
Parameters:
xsdDateTime -
Returns:
Throws:
Exception

newInstanceFromXsdString

public static JbbDate newInstanceFromXsdString(String xsdDateTime,
                                               Locale locale)
                                        throws Exception
Parameters:
xsdDateTime -
Returns:
Throws:
Exception

newInstanceFromXsdString

public static JbbDate newInstanceFromXsdString(String xsdDateTime)
                                        throws Exception
Parameters:
xsdDateTime -
Returns:
Throws:
Exception

newInstanceFromRfc822String

public static JbbDate newInstanceFromRfc822String(String xsdDateTime,
                                                  Locale locale,
                                                  TimeZone timeZone)
                                           throws Exception
Parameters:
xsdDateTime -
Returns:
Throws:
Exception

newInstanceFromRfc822String

public static JbbDate newInstanceFromRfc822String(String xsdDateTime,
                                                  Locale locale)
                                           throws Exception
Parameters:
xsdDateTime -
Returns:
Throws:
Exception

newInstanceFromRfc822String

public static JbbDate newInstanceFromRfc822String(String xsdDateTime)
                                           throws Exception
Parameters:
xsdDateTime -
Returns:
Throws:
Exception

getCalendar

public Calendar getCalendar()
Returns:
a Calendar instance initialized with the proper locale and time zone

getDate

public Date getDate()
Returns:
the reference date

formatDate

public String formatDate()
the formatting is based on the current locale

Returns:
the date as a string in the default format for the current locale

formatDateMedium

public String formatDateMedium()
Returns:
the date as a string in short format (MEDIUM is longer, such as Jan 12, 1952 )

formatDateLong

public String formatDateLong()
Returns:
the date as a string in short format (LONG is longer, such as January 12, 1952 or 3:30:32pm)

formatDateFull

public String formatDateFull()
Returns:
the date as a string in short format (FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST)

formatDateShort

public String formatDateShort()
format the date as a string in short format (SHORT is completely numeric, such as 12.13.52 or 3:30pm).

Returns:
string

formatDateTime

public String formatDateTime()
format the date as a string in the default format for the current locale the formatting is based on the current locale


formatDateTimeShort

public String formatDateTimeShort()
format the date as a string in short format (SHORT is completely numeric, such as 12.13.52 or 3:30pm).

Returns:
string

formatDateTimeMedium

public String formatDateTimeMedium()
format the date as a string in short format (MEDIUM is longer, such as Jan 12, 1952 ).

Returns:
string

formatDateTimeLong

public String formatDateTimeLong()
format the date as a string in short format (LONG is longer, such as January 12, 1952 or 3:30:32pm).

Returns:
string

formatDateTimeFull

public String formatDateTimeFull()
format the date as a string in short format (FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST).

Returns:
string

formatTime

public String formatTime()
format the date as a string in the default format for the current locale the formatting is based on the current locale

Returns:
string

formatTimeShort

public String formatTimeShort()
format the date as a string in short format (SHORT is completely numeric, such as 12.13.52 or 3:30pm).

Returns:
string

formatTimeMedium

public String formatTimeMedium()
format the date as a string in short format (MEDIUM is longer, such as Jan 12, 1952 ).

Returns:
string

formatTimeLong

public String formatTimeLong()
format the date as a string in short format (LONG is longer, such as January 12, 1952 or 3:30:32pm).

Returns:
string

formatTimeFull

public String formatTimeFull()
format the date as a string in short format (FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST).

Returns:
string

getPreviousDay

public JbbDate getPreviousDay()
Returns:
the date that corresponds to the beginning of the previous day of the reference date. For instance, if December 14 2:56 PM is the input, the method returns December 13 00:00:00:000

setPreviousDay

public void setPreviousDay()
calls the getPreviousDay() and changes the internal state to the return value.


getPreviousNDay

public JbbDate getPreviousNDay(int nbDays)
Parameters:
nbDays - the number of days
Returns:
the date that corresponds to the beginning of the previous day (i.e. 00:00:00:000) of the reference date. For instance, if December 14 2:56 PM is the input, the method returns December 13 00:00:00:000

setPreviousNDay

public void setPreviousNDay(int nbDays)
calls the getPreviousNDay() and changes the internal state to the return value.


isBusinessDay

public boolean isBusinessDay()
Returns:
true if the reference date is a business day (Monday,Tuesday,Wednesday,Thursday and Friday) and false if it is a week-end day (Saturday,Sunday)

getPreviousBusinessDay

public JbbDate getPreviousBusinessDay()
Returns:
the date that corresponds to the previous business day (Same hour,minute...) For instance, if Sunday December 14 2:56 PM is the input, the method returns Friday December 12 2:56 PM

setPreviousBusinessDay

public void setPreviousBusinessDay()
calls the getPreviousBusinessDay() and changes the internal state to the return value.


getPreviousNBusinessDay

public JbbDate getPreviousNBusinessDay(int nbOfBusinessDays)
Parameters:
nbOfBusinessDays - the number of business days
Returns:
the date that corresponds to the following nbOfBusinessDays business day For instance, if Sunday December 14 2:56 PM 2003 and 3 are the inputs, the method returns Wednesday December 17 2003 2:56 PM Similarly, if Wednesday January 14 2004 2:56 PM and 4 are the inputs, the method returns Tuesday January 20 2004 2:56 PM

setPreviousNBusinessDay

public void setPreviousNBusinessDay(int nbOfBusinessDays)
calls the getPreviousNBusinessDay(nbOfBusinessDays) and changes the internal state to the return value.


getNextBusinessDay

public JbbDate getNextBusinessDay()
Returns:
the date that corresponds to the following business day For instance, if Sunday December 14 2:56 PM is the input, the method returns Monday December 15 2:56 PM

setNextBusinessDay

public void setNextBusinessDay()
calls the getNextBusinessDay() and changes the internal state to the return value.


getNextNBusinessDay

public JbbDate getNextNBusinessDay(int nbOfBusinessDays)
Parameters:
nbOfBusinessDays - the number of business days
Returns:
the date that corresponds to the following nbOfBusinessDays business day For instance, if Sunday December 14 2:56 PM 2003 and 3 are the inputs, the method returns Wednesday December 17 2003 2:56 PM Similarly, if Wednesday January 14 2004 2:56 PM and 4 are the inputs, the method returns Tuesday January 20 2004 2:56 PM

setNextNBusinessDay

public void setNextNBusinessDay(int nbOfBusinessDays)
calls the getNextNBusinessDay(nbOfBusinessDays) and changes the internal state to the return value.


getEndOfDay

public JbbDate getEndOfDay()
Returns:
the date that corresponds to the end of the reference date

setEndOfDay

public void setEndOfDay()
calls the getEndOfDay() and changes the internal state to the return value.


getBeginningOfDay

public JbbDate getBeginningOfDay()
Returns:
the date that corresponds to the beginning of the reference date

setBeginningOfDay

public void setBeginningOfDay()
calls the getBeginningOfDay() and changes the internal state to the return value.


getBeginningOfWeek

public JbbDate getBeginningOfWeek()
Returns:
the date that corresponds to the beginning of the week of the reference date

setBeginningOfWeek

public void setBeginningOfWeek()
calls the getBeginningOfWeek() and changes the internal state to the return value.


getEndOfWeek

public JbbDate getEndOfWeek()
Returns:
the date that corresponds to the end of the week of the reference date

setEndOfWeek

public void setEndOfWeek()
calls the getEndOfWeek() and changes the internal state to the return value.


getPreviousWeek

public JbbDate getPreviousWeek()
Returns:
the date that corresponds to the beginning of the previous week of the reference date

setPreviousWeek

public void setPreviousWeek()
calls the getPreviousWeek() and changes the internal state to the return value.


getPreviousNWeek

public JbbDate getPreviousNWeek(int nbWeeks)
Parameters:
nbWeeks - 1 for the previous week...
Returns:
the date that corresponds to the beginning of the previous N week of the reference date

setPreviousNWeek

public void setPreviousNWeek(int nbWeeks)
calls the getPreviousNWeek(nbWeeks) and changes the internal state to the return value.


getPreviousMonth

public JbbDate getPreviousMonth()
Returns:
the date that corresponds to the beginning of the previous N months of the reference date

setPreviousMonth

public void setPreviousMonth()
calls the getPreviousMonth() and changes the internal state to the return value.


getPreviousNMonth

public JbbDate getPreviousNMonth(int nbMonth)
Parameters:
nbMonth -
Returns:
the date that corresponds to the beginning of the previous N months of the reference date

setPreviousNMonth

public void setPreviousNMonth(int nbMonth)
calls the getPreviousNMonth(int nbMonth) and changes the internal state to the return value.


getBeginningOfMonth

public JbbDate getBeginningOfMonth()
Returns:
the date that corresponds to the beginning of the month of the reference date

setBeginningOfMonth

public void setBeginningOfMonth()
calls the getBeginningOfMonth() and changes the internal state to the return value.


getBeginningOfMonth

public JbbDate getBeginningOfMonth(int month)
Returns:
the date that corresponds to the beginning of the month of the reference date

setBeginningOfMonth

public void setBeginningOfMonth(int month)
calls the getBeginningOfMonth(int month) and changes the internal state to the return value.


getEndOfMonth

public JbbDate getEndOfMonth()
Returns:
the date that corresponds to the end of the month of the reference date

setEndOfMonth

public void setEndOfMonth()
calls the getEndOfMonth() and changes the internal state to the return value.


getEndOfMonth

public JbbDate getEndOfMonth(int month)
Returns:
the date that corresponds to the end of the month of the reference date

setEndOfMonth

public void setEndOfMonth(int month)
calls the getEndOfMonth(int month) and changes the internal state to the return value.


getNextDay

public JbbDate getNextDay()
Returns:
the date that corresponds to the following day (same hour, minute...) of the reference date

setNextDay

public void setNextDay()
calls the getNextDay() and changes the internal state to the return value.


getNextNDay

public JbbDate getNextNDay(int numberOfDaysToAdd)
Parameters:
numberOfDaysToAdd -
Returns:
the date that corresponds to the reference date plus the number of given days. For instance,
  • if the inputs are "February 5, 2004" and "5", the result is "February 10, 2004"
  • if the inputs are "February 28, 2004" and "1", the result is "February 29, 2004"
  • if the inputs are "February 28, 2004" and "2", the result is "March 1, 2004"
  • if the inputs are "December 24, 2003" and "8", the result is "January 1, 2004"

setNextNDay

public void setNextNDay(int numberOfDaysToAdd)
calls the getNextNDay(numberOfDaysToAdd) and changes the internal state to the return value.


getNextWeek

public JbbDate getNextWeek()
Returns:
the date that corresponds to the following week of the reference date

setNextWeek

public void setNextWeek()
calls the getNextWeek() and changes the internal state to the return value.


getNextNWeek

public JbbDate getNextNWeek(int nbWeeks)
Returns:
the date that corresponds to the following N weeks of the reference date

setNextNWeek

public void setNextNWeek(int nbWeeks)
calls the getNextNWeek(nbWeeks) and changes the internal state to the return value.


getNextMonth

public JbbDate getNextMonth()
Returns:
the date that corresponds to the following month of the reference date

setNextMonth

public void setNextMonth()
calls the getNextMonth() and changes the internal state to the return value.


getNextNMonth

public JbbDate getNextNMonth(int nbMonths)
Returns:
the date that corresponds to the following N month of the reference date

setNextNMonth

public void setNextNMonth(int nbMonths)
calls the getNextNMonth(int nbMonths) and changes the internal state to the return value.


setNthDayOfWeekOnOrAfter

public void setNthDayOfWeekOnOrAfter(int dayOfTheWeek,
                                     int hour,
                                     int minute,
                                     int second,
                                     int millisecond)
calls the getNthDayOfWeekOnOrAfter(int dayOfTheWeek, int hour, int minute, int second, int millisecond) and changes the internal state to the return value.


getSameDayWithDifferentTime

public JbbDate getSameDayWithDifferentTime(int hour,
                                           int minute,
                                           int second,
                                           int millisecond)
Parameters:
hour - 0 to 23
minute - 0 to 59
second - 0 to 59
millisecond - 0 to 999
Returns:
the date corresponding to the same day of the reference date but with the given hour,minute,second and millisecond
This method can also be used in conjunction with the other DateHandler methods to provide more advanced date manipulation. For instance, to obtain the date corresponding to tomorrow at 3:00 PM, you would use:
Date tomorrow = DateHandler.getNextDay();
Date tomorrowAt3PM = DateHandler.getSameDay(tomorrow,3,0,0,0);

setSameDayWithDifferentTime

public void setSameDayWithDifferentTime(int hour,
                                        int minute,
                                        int second,
                                        int millisecond)
calls the getSameDayWithDifferentTime(int hour, int minute, int second, int millisecond) and changes the internal state to the return value.


isSameDay

public boolean isSameDay(Date inputDate)
Parameters:
inputDate - the second date
Returns:
true if the reference date and inputDate are two dates in the same day (i.e. within 00:00:00:000 to 23:59:59:999)

isDateAfterDate2PlusNDays

public boolean isDateAfterDate2PlusNDays(Date d2,
                                         int nbDays)
Parameters:
d1 -
d2 -
nbDays -
Returns:
true if the reference date is after the date d2 plus the given number of days. For instance:
if the reference date is Tuesday January 11 2005 6:25 PM and if d2 is Saturday 8 2005 6:00 PM, the call isDate1AfterDate2PlusNDays(d1,d2,3) would return true (d1 is after d2 + 3 days which is Tuesday January 11 2005 6:00 PM)
if the reference date is Tuesday January 11 2005 6:25 PM and if d2 is Saturday 8 2005 6:00 PM, the call isDate1AfterDate2PlusNDays(d1,d2,4) would return false (d1 is not after d2 + 4 days which is Wednesday January 12 2005 6:00 PM)

isDateAfterDate2MinusNDays

public boolean isDateAfterDate2MinusNDays(Date d2,
                                          int nbDays)
Parameters:
d2 -
nbDays -
Returns:
true if the reference date is after the date d2 minus the given number of days. For instance:
if the reference date is Saturday 8 2005 6:00 PM and if d2 is Tuesday January 11 2005 6:25 PM, the call isDate1AfterDate2MinusNDays(d2,4) would return true (the reference date is after d2 - 4 days which is Friday January 7 2005 6:25 PM)
if the reference date is Saturday 8 2005 6:00 PM and if d2 is Tuesday January 11 2005 6:25 PM, the call isDate1AfterDate2MinusNDays(d2,3) would return false (the reference date is not after d2 - 3 days which is Saturday January 8 2005 6:25 PM)

isDateBeforeDate2PlusNDays

public boolean isDateBeforeDate2PlusNDays(Date d2,
                                          int nbDays)
Parameters:
d2 -
nbDays -
Returns:
true if the reference date is before the date d2 plus the given number of days. For instance:
if the reference date is Tuesday January 11 2005 6:00 PM and if d2 is Saturday 8 2005 6:25 PM, the call isDate1BeforeDate2PlusNDays(d1,d2,3) would return true (the reference date is before d2 + 3 days which is Tuesday January 11 2005 6:25 PM)
if the reference date is Tuesday January 11 2005 6:25 PM and if d2 is Saturday 8 2005 6:00 PM, the call isDate1BeforeDate2PlusNDays(d1,d2,3) would return false (the reference date is not after d2 + 3 days which is Wednesday January 12 2005 6:00 PM)

isDateBeforeDate2MinusNDays

public boolean isDateBeforeDate2MinusNDays(Date d2,
                                           int nbDays)
Parameters:
d2 -
nbDays -
Returns:
true if the reference date is before the date d2 minus the given number of days. For instance:
if the reference date is Saturday 8 2005 6:00 PM and if d2 is Tuesday January 11 2005 6:25 PM, the call isDate1AfterDate2MinusNDays(d1,d2,3) would return true (the reference date is before d2 - 3 days which is Saturday January 8 2005 6:25 PM)
if the reference date is Saturday 8 2005 6:00 PM and if d2 is Tuesday January 11 2005 6:25 PM, the call isDate1AfterDate2MinusNDays(d2,4) would return false (the reference date is not after d2 - 4 days which is Friday January 7 2005 6:25 PM)

isDateAfterDate2MinusNDaysAndBeforeDate2PlusNDays

public boolean isDateAfterDate2MinusNDaysAndBeforeDate2PlusNDays(Date d2,
                                                                 int nbDays)
Parameters:
d2 -
nbDays -
Returns:
true if the reference date is within the range of d2 minus the given number of days and d2 plus the given number of days. For instance:
if the reference date is Saturday 8 2005 6:00 PM and if d2 is Tuesday January 11 2005 6:25 PM, the call isDate1AfterDate2MinusNDays(d1,d2,4) would return true (the reference date is after d2 - 4 days which is Friday 7 2005 6:25 PM and before Satruday 15)
if the reference date is Saturday 8 2005 6:00 PM and if d2 is Tuesday January 11 2005 6:25 PM, the call isDate1AfterDate2MinusNDays(d1,d2,2) would return false (the reference date is not after d2 - 2 days which is Sunday January 9 2005 6:25 PM)

isDateAfterDate2AndBeforeDate3

public boolean isDateAfterDate2AndBeforeDate3(Date d2,
                                              Date d3)
Parameters:
d2 -
d3 -
Returns:
true if the reference date is equal to or after the date d2 and before d3

getNbOfYearsBetweenDates

public int getNbOfYearsBetweenDates()
                             throws JbbInvalidArgumentException
Parameters:
birthDate -
Returns:
the age in number of years between the reference date and the current system time
Throws:
JbbInvalidArgumentException - when the birthDate is after the current system date

getNbOfYearsBetweenDates

public int getNbOfYearsBetweenDates(Date inputDate)
                             throws JbbInvalidArgumentException
Parameters:
inputDate -
Returns:
the number of years between the given inputDate and the reference date (the result is always positive whether the inputDate is before or after the reference date)
Throws:
JbbInvalidArgumentException - when the birth date is after the reference date or when birthDate is null

getBeginningOfYear

public JbbDate getBeginningOfYear()
Returns:
the date that corresponds to the beginning of the year of the reference year

setBeginningOfYear

public void setBeginningOfYear()
calls the getBeginningOfYear() and changes the internal state to the return value.


getEndOfYear

public JbbDate getEndOfYear()
Returns:
the date that corresponds to the end of the year of the reference date

setEndOfYear

public void setEndOfYear()
calls the getEndOfYear() and changes the internal state to the return value.


getNbOfMiliisecondsBetweenDates

public long getNbOfMiliisecondsBetweenDates()
Parameters:
inputDate -
Returns:
the number of milliseconds between the reference date and the current system time
Throws:
Exception

getNbOfMillisecondsBetweenDates

public long getNbOfMillisecondsBetweenDates(Date inputDate)
Parameters:
inputDate -
Returns:
the number of milliseconds between the reference date and the input date
Throws:
Exception

getNbOfSecondsBetweenDates

public long getNbOfSecondsBetweenDates()
Parameters:
inputDate -
Returns:
the number of seconds between the reference date and the current system time
Throws:
Exception

getNbOfSecondsBetweenDates

public long getNbOfSecondsBetweenDates(Date inputDate)
Parameters:
inputDate -
Returns:
the number of seconds between the reference date and the input date
Throws:
Exception

getNbOfMinutesBetweenDates

public long getNbOfMinutesBetweenDates()
Parameters:
inputDate -
Returns:
the number of minutes between the reference date and the current system time
Throws:
Exception

getNbOfMinutesBetweenDates

public long getNbOfMinutesBetweenDates(Date inputDate)
Parameters:
inputDate -
Returns:
the number of minutes between the reference date and the input date
Throws:
Exception

getNbOfHoursBetweenDates

public long getNbOfHoursBetweenDates()
Parameters:
inputDate -
Returns:
the number of minutes between the reference date and the current system time. Please note that the method will return 0 if the difference is 30 minutes
Throws:
Exception

getNbOfHoursBetweenDates

public long getNbOfHoursBetweenDates(Date inputDate)
Parameters:
inputDate -
Returns:
the number of minutes between the reference date and the input date
Throws:
Exception

getNbOfDaysBetweenDates

public int getNbOfDaysBetweenDates()
Parameters:
inputDate -
Returns:
the number of days between the reference date and the current system time
Throws:
Exception

getNbOfDaysBetweenDates

public int getNbOfDaysBetweenDates(Date inputDate)
Parameters:
inputDate -
Returns:
the number of days between the reference date and the input date
Throws:
Exception

getYear

public int getYear()
Returns:
the year of the reference date (e.g. 2007 for the year 2007)

getMonth

public int getMonth()
Returns:
the month (0 for January,... 11 for December) of the reference date

getDayOfYear

public int getDayOfYear()
Returns:
the day of the year for the reference date

getDayOfMonth

public int getDayOfMonth()
Returns:
the day of the month for the reference date

getDayOfWeek

public int getDayOfWeek()
Returns:

getHour

public int getHour()
Returns:
the hour of the reference date

getMinute

public int getMinute()
Returns:
the minute of the reference date

getSecond

public int getSecond()
Returns:
the second of the reference date

getMilliSecond

public int getMilliSecond()
Returns:
the number of millisecond of the reference date

getDifference

public JbbDateDifference getDifference(Date dateToCompare)
Parameters:
dateToCompare -
Returns:
the JbbDateDifference instance that represents the difference between the dateToCompare and the referenceDate

getQuarter

public int getQuarter()
Returns:
the quarter for the reference date (1 - 4)

getIntervalsForEntireYear

public JbbDateIntervalsYear getIntervalsForEntireYear()
                                               throws Exception
Returns:
a list of the entire set of date intervals for the year of the reference date ordered by chronological order:
a DateFromToType instance for the week 1
a DateFromToType instance for the week 2
a DateFromToType instance for the week 3
a DateFromToType instance for the week 4
a DateFromToType instance for the week 5
a DateFromToType instance for the month 1
a DateFromToType instance for the week 6
...
a DateFromToType instance for the quarter4
a DateFromToType instance for the year
To distinguish the different types of date interval, the field "type" of the DateFromToType instances is set to:
  • 1 for a week
  • 2 for a month
  • 3 for a quarter
  • 4 for a year
Throws:
Exception

getIntervals

public JbbDateIntervalsDate getIntervals(boolean doNotExtend)
                                  throws Exception
Parameters:
doNotExtend - if true, the end date of each date interval is set to the end of the week that contains the reference day. For instance, the week interval is set to (assuming USA locale):
  • Sunday May 21 to Saturday May 26 if the reference date is Tuesday May 23 and if doNotExtend is false
  • Sunday May 21 to Tuesday May 23 if the reference date is Tuesday May 23 and if doNotExtend is true
Returns:
a DateIntervalsDate instance populated for the reference date. The instance contains the time intervals corresponding:
  • the week interval that contains the reference date
  • the month interval that contains the reference date
  • the quarter interval that contains the reference date
  • the year interval that contains the reference date
Throws:
Exception

getBeginningOfQuarter

public JbbDate getBeginningOfQuarter()
                              throws Exception
Returns:
the date corresponding to the beginning of the quarter for the reference date
Throws:
Exception

setBeginningOfQuarter

public void setBeginningOfQuarter()
                           throws Exception
calls the getBeginningOfQuarter() and changes the internal state to the return value.

Throws:
Exception

getEndOfQuarter

public JbbDate getEndOfQuarter()
                        throws Exception
Returns:
the date corresponding to the end of the quarter for the reference date
Throws:
Exception

setEndOfQuarter

public void setEndOfQuarter()
                     throws Exception
calls the getEndOfQuarter() and changes the internal state to the return value.

Throws:
Exception

getBeginningOfQuarter

public JbbDate getBeginningOfQuarter(int quarterNumber)
                              throws Exception
Parameters:
quarterNumber - 1 for Q1, ... 4 for Q4
Returns:
the date corresponding to the beginning of the given quarter number in the year of the reference date
Throws:
Exception

setBeginningOfQuarter

public void setBeginningOfQuarter(int quarterNumber)
                           throws Exception
calls the getBeginningOfQuarter(int quarterNumber) and changes the internal state to the return value.

Throws:
Exception

getEndOfQuarter

public JbbDate getEndOfQuarter(int quarterNumber)
                        throws Exception
Parameters:
quarterNumber - 1 for Q1, ... 4 for Q4
Returns:
the date corresponding to the end of the given quarter number in the year of the reference date
Throws:
Exception

setEndOfQuarter

public void setEndOfQuarter(int quarterNumber)
                     throws Exception
calls the getEndOfQuarter(int quarterNumber) and changes the internal state to the return value.

Throws:
Exception

getNthDayOfMonth

public JbbDate getNthDayOfMonth(int dayNumber)
                         throws Exception
Parameters:
dayNumber - 1 to 31
Returns:
the Nth day of the month of the reference date
Throws:
Exception

setNthDayOfMonth

public void setNthDayOfMonth(int dayNumber)
                      throws Exception
calls the getNthDayOfMonth(int dayNumber) and changes the internal state to the return value.

Throws:
Exception

getNthDayOfYear

public JbbDate getNthDayOfYear(int dayNumber)
                        throws Exception
Parameters:
dayNumber - 1 to 365
Returns:
the Nth day of the year of the reference date
Throws:
Exception

setNthDayOfYear

public void setNthDayOfYear(int dayNumber)
                     throws Exception
calls the getNthDayOfYear(int dayNumber) and changes the internal state to the return value.

Throws:
Exception

getPreviousYear

public JbbDate getPreviousYear()
Returns:

setPreviousYear

public void setPreviousYear()
                     throws Exception
calls the getPreviousYear() and changes the internal state to the return value.

Throws:
Exception

getPreviousNYear

public JbbDate getPreviousNYear(int nbYears)
Parameters:
nbYears -
Returns:

setPreviousNYear

public void setPreviousNYear(int nbYears)
                      throws Exception
calls the getPreviousNYear(int nbYears) and changes the internal state to the return value.

Throws:
Exception

getNextYear

public JbbDate getNextYear()
Returns:

setNextYear

public void setNextYear()
                 throws Exception
calls the getNextYear() and changes the internal state to the return value.

Throws:
Exception

getNextNYears

public JbbDate getNextNYears(int nbYears)
Parameters:
nbYears -
Returns:

setNextNYears

public void setNextNYears(int nbYears)
                   throws Exception
calls the getNextNYears(nbYears) and changes the internal state to the return value.

Throws:
Exception

formatDateXsd

public String formatDateXsd()
Returns:

formatDate

public String formatDate(String format)
                  throws Exception
Parameters:
format - the format string. It is a String which may contain fixed text and one or more embedded format specifiers. Consider the following example:

String s = String.format("Today is: %1$tY-%1$tm-%1$td",new Date());
-> When called on the 23rd of April 2007, the returned String would be "Today is 2007-04-23"

The format specifiers for types which are used to represents dates and times have the following syntax:
%1$tconversion

The following conversion characters are used for formatting dates: 'B' Locale-specific full month name, e.g. "January", "February". //'b' Locale-specific abbreviated month name, e.g. "Jan", "Feb". //'h' Same as 'b'. //'A' Locale-specific full name of the day of the week, e.g. "Sunday", "Monday" //'a' Locale-specific short name of the day of the week, e.g. "Sun", "Mon" //'C' Four-digit year divided by 100, formatted as two digits with leading zero as necessary, i.e. 00 - 99 //'Y' Year, formatted as at least four digits with leading zeros as necessary, e.g. 0092 equals 92 CE for the Gregorian calendar. //'y' Last two digits of the year, formatted with leading zeros as necessary, i.e. 00 - 99. //'j' Day of year, formatted as three digits with leading zeros as necessary, e.g. 001 - 366 for the Gregorian calendar. //'m' Month, formatted as two digits with leading zeros as necessary, i.e. 01 - 13. //'d' Day of month, formatted as two digits with leading zeros as necessary, i.e. 01 - 31 //'e' Day of month, formatted as two digits, i.e. 1 - 31.

//The following conversion characters are used for formatting common date/time compositions. //'D' Date formatted as "%tm/%td/%ty". //'F' ISO 8601 complete date formatted as "%tY-%tm-%td".

Throws:
Exception

formatDateTime

public String formatDateTime(String format)
                      throws Exception
Parameters:
format - the format string. It is a String which may contain fixed text and one or more embedded format specifiers. Consider the following example:

String s = String.format("Today is: %1$tY-%1$tm-%1$td",new Date());
-> When called on the 23rd of April 2007, the returned String would be "Today is 2007-04-23"

The format specifiers for types which are used to represents dates and times have the following syntax:
%1$conversion

The following conversion characters are used for formatting times: 'H' Hour of the day for the 24-hour clock, formatted as two digits with a leading zero as necessary i.e. 00 - 23. 'I' Hour for the 12-hour clock, formatted as two digits with a leading zero as necessary, i.e. 01 - 12. 'k' Hour of the day for the 24-hour clock, i.e. 0 - 23. 'l' Hour for the 12-hour clock, i.e. 1 - 12. 'M' Minute within the hour formatted as two digits with a leading zero as necessary, i.e. 00 - 59. 'S' Seconds within the minute, formatted as two digits with a leading zero as necessary, i.e. 00 - 60 ("60" is a special value required to support leap seconds). 'L' Millisecond within the second formatted as three digits with leading zeros as necessary, i.e. 000 - 999. 'N' Nanosecond within the second, formatted as nine digits with leading zeros as necessary, i.e. 000000000 - 999999999. 'p' Locale-specific morning or afternoon marker in lower case, e.g."am" or "pm". Use of the conversion prefix 'T' forces this output to upper case. 'z' RFC 822 style numeric time zone offset from GMT, e.g. -0800. 'Z' A string representing the abbreviation for the time zone. The Formatter's locale will supersede the locale of the argument (if any). 's' Seconds since the beginning of the epoch starting at 1 January 1970 00:00:00 UTC, i.e. Long.MIN_VALUE/1000 to Long.MAX_VALUE/1000. 'Q' Milliseconds since the beginning of the epoch starting at 1 January 1970 00:00:00 UTC, i.e. Long.MIN_VALUE to Long.MAX_VALUE.

The following conversion characters are used for formatting dates: 'B' Locale-specific full month name, e.g. "January", "February". //'b' Locale-specific abbreviated month name, e.g. "Jan", "Feb". //'h' Same as 'b'. //'A' Locale-specific full name of the day of the week, e.g. "Sunday", "Monday" //'a' Locale-specific short name of the day of the week, e.g. "Sun", "Mon" //'C' Four-digit year divided by 100, formatted as two digits with leading zero as necessary, i.e. 00 - 99 //'Y' Year, formatted as at least four digits with leading zeros as necessary, e.g. 0092 equals 92 CE for the Gregorian calendar. //'y' Last two digits of the year, formatted with leading zeros as necessary, i.e. 00 - 99. //'j' Day of year, formatted as three digits with leading zeros as necessary, e.g. 001 - 366 for the Gregorian calendar. //'m' Month, formatted as two digits with leading zeros as necessary, i.e. 01 - 13. //'d' Day of month, formatted as two digits with leading zeros as necessary, i.e. 01 - 31 //'e' Day of month, formatted as two digits, i.e. 1 - 31.

//The following conversion characters are used for formatting common date/time compositions. //'R' Time formatted for the 24-hour clock as "%tH:%tM" //'T' Time formatted for the 24-hour clock as "%tH:%tM:%tS". //'r' Time formatted for the 12-hour clock as "%tI:%tM:%tS %Tp". The location of the morning or afternoon marker ('%Tp') may be locale-dependent. //'D' Date formatted as "%tm/%td/%ty". //'F' ISO 8601 complete date formatted as "%tY-%tm-%td". //'c' Date and time formatted as "%ta %tb %td %tT %tZ %tY", e.g. "Sun Jul 20 16:17:00 EDT 1969".

Throws:
Exception

setYear

public void setYear(int year)
calls the getYear(year) and changes the internal state to the return value.


getYear

public JbbDate getYear(int year)
Parameters:
year - to set
Returns:
new JbbDate with year changed to the given year.

setMonth

public void setMonth(int month)
              throws Exception
calls the getMonth(month) and changes the internal state to the return value.

Throws:
Exception

getMonth

public JbbDate getMonth(int month)
                 throws Exception
Parameters:
year - to set
Returns:
new JbbDate with year changed to the given year.
Throws:
Exception

compareTo

public int compareTo(Date date)
convenience method to compare a JbbDate instance with a Date instance

See Also:
Comparable.compareTo(java.lang.Object)

compareTo

public int compareTo(JbbDate date)
convenience method to compare 2 JbbDate instance

Specified by:
compareTo in interface Comparable<JbbDate>
See Also:
Comparable.compareTo(java.lang.Object)

getTimeZone

public TimeZone getTimeZone()
Returns:

getLocale

public Locale getLocale()
Returns:

formatDateTimeXsd

public String formatDateTimeXsd()
The xsd:dateTime format is described in chapter 4 of ISO 8601 and the W3C consortium (http://www.w3.org/TR/NOTE-datetime )
In a nutshell, the format is:
YYYY-MM-DDThh:mm:ss.SSS[Z|(+|-)hh:mm]
The time zone may be specified as Z (UTC) or (+|-)hh:mm.

Returns:
the date encoded in the xsd:dateTime format

formatDateTimeRfc822

public String formatDateTimeRfc822()
The RFC 2822 date and timeis described as: // rfc1123-date = wkday "," SP date1 SP time SP "GMT" // date1 = 2DIGIT SP month SP 4DIGIT // ; day month year (e.g., 02 Jun 1982) // time = 2DIGIT ":" 2DIGIT ":" 2DIGIT // ; 00:00:00 - 23:59:59 // wkday = "Mon" | "Tue" | "Wed" // | "Thu" | "Fri" | "Sat" | "Sun" // month = "Jan" | "Feb" | "Mar" | "Apr" // | "May" | "Jun" | "Jul" | "Aug" // | "Sep" | "Oct" | "Nov" | "Dec"
Sample: "Mon, 26 Feb 2007 21:23:14 +0100"

Returns:
the date encoded in the xsd:dateTime format

getWeek

public int getWeek()
Returns:
the week number (1 - 53) as defined by ISO 8601 (see http://en.wikipedia.org/wiki/ISO_8601#Week_dates)
For instance, if the date is Sunday January 7th, 2007
getWeek() returns 2 for the US locale
getWeek() returns 1 for the FRANCE locale
Similarly, if the given date is Saturday December 29th, 2007, getWeek() returns 52
Please note that weeks overlap from year to year, for instance:
  • if the given date is Saturday December 29th, 2007, getWeek() returns 52
  • if the given date is Monday December 31th, 2007, getWeek() returns 53
  • if the given date is Tuesday January 1st, 2008, getWeek() returns 1

getNthDayOfWeek

public JbbDate getNthDayOfWeek(int weekNumber,
                               int dayNumber)
Parameters:
weekNumber - 1 - 53
dayNumber - 1 - 7
Returns:
the date corresponding the Nth day of the given week in the year and locale of the reference date

getBeginningOfWeek

public JbbDate getBeginningOfWeek(int weekNumber)
Parameters:
weekNumber - 1 to 52
Returns:
date

setBeginningOfWeek

public void setBeginningOfWeek(int weekNumber)
calls the getBeginningOfWeek(weekNumber) and changes the internal state to the return value.


getEndOfWeek

public JbbDate getEndOfWeek(int weekNumber)
Parameters:
weekNumber -
year -
Returns:
date

setEndOfWeek

public void setEndOfWeek(int weekNumber)
                  throws Exception
calls the getEndOfWeek(weekNumber) and changes the internal state to the return value.

Throws:
Exception

getNthDayOfWeek

public JbbDate getNthDayOfWeek(int dayNumber)
                        throws Exception
Parameters:
dayNumber -
Returns:
the Nth day of the week of the reference date
Throws:
Exception

setNthDayOfWeek

public void setNthDayOfWeek(int dayNumber)
                     throws Exception
calls the getNthDayOfWeek(int dayNumber) and changes the internal state to the return value.

Throws:
Exception

setNthDayOfWeek

public void setNthDayOfWeek(int weekNumber,
                            int dayNumber)
                     throws Exception
calls the getNthDayOfWeek(int weekNumber, int dayNumber) and changes the internal state to the return value.

Throws:
Exception

getNthDayOfWeekOnOrAfter

public JbbDate getNthDayOfWeekOnOrAfter(int dayOfTheWeek,
                                        int hour,
                                        int minute,
                                        int second,
                                        int millisecond)
Parameters:
dayOfTheWeek - the desired day of week (e.g. Calendar.TUESDAY)
hour - the desired hour (0 to 23)
minute - the desired minute (0 to 59)
second - the desired second (0 to 59)
millisecond - the desired millisecond (0 to 999)
Returns:
The date corresponding to the first desired day of week (with desired hour, minute, second and millisecond) that is on or after the reference date
For instance, getNthDayOfWeekOnOrAfterTheReferenceDate(Calendar.TUESDAY,3,0,0,0) returns the date of the first Tuesday at 3:00 AM on or after the reference date:
  • If the reference date is a Monday at 6:00 PM, it will return the following Tuesday at 3:00 AM
  • If the reference date is a Tuesday at 2.45 AM, it will return that Tuesday at 3:00 AM
  • If the reference date is a Tuesday at 3:15 AM, it will return the Tuesday of the following week at 3:00 AM
  • In the specific case where the reference date is a tuesday at 3.00:00 000, it will return the exact same date


Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.