com.cc.framework.util
Class CalendarHelp

java.lang.Object
  extended bycom.cc.framework.util.CalendarHelp

public abstract class CalendarHelp
extends java.lang.Object

Calendar utility class

Version:
$Revision: 1.13 $
Author:
Harald Schulz

Field Summary
static int DAYS_IN_WEEK
          The number of days in a week
static int DOWM_ALLDAYS
          Bit mask for Working Days
static int DOWM_FRIDAY
          Bit mask for Friday
static int DOWM_MONDAY
          Bit mask for Monday
static int DOWM_SATURDAY
          Bit mask for Saturday
static int DOWM_SUNDAY
          Bit mask for Sunday
static int DOWM_THURSDAY
          Bit mask for Thursday
static int DOWM_TUESDAY
          Bit mask for Tuesday
static int DOWM_WEDNESDAY
          Bit mask for Wednesday
static int DOWM_WEEKDAYS
          Bit mask for Working Days
static int DOWM_WEEKENDDAYS
          Bit mask for Weekend Days
 
Constructor Summary
CalendarHelp()
           
 
Method Summary
static boolean between(java.util.Calendar date, java.util.Calendar t1, java.util.Calendar t2)
          This method checks if the given date falls between the dates t1 and t2.
static int getDays(java.util.Calendar date1, java.util.Calendar date2)
          This method calculates the number of days between the two dates.
static boolean isSameDay(java.util.Calendar a, java.util.Calendar b)
          Checks if both dates are on the same day
static boolean isWeekEndDay(int dayOfWeek)
          Checks if the given day is a weekend day
static int parseDay(java.lang.String dayName)
          Converts a Day Name into a integer value
static int parseDayMask(java.lang.String dayList)
          Parses a semicolon separated Day list and creates a day mask
static int rollDay(int dayOfWeek, int offset)
          Rolls the day index by the given offset
static void setFromLong(java.util.Calendar cal, long timeInMillis)
          Initializes the calendar with the given UTC timestamp for compatibility with JDK 1.3
static long toLong(java.util.Calendar cal)
          Converts a calendar into a long value for compatibility with JDK 1.3
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DAYS_IN_WEEK

public static final int DAYS_IN_WEEK
The number of days in a week

See Also:
Constant Field Values

DOWM_SUNDAY

public static final int DOWM_SUNDAY
Bit mask for Sunday

See Also:
Constant Field Values

DOWM_MONDAY

public static final int DOWM_MONDAY
Bit mask for Monday

See Also:
Constant Field Values

DOWM_TUESDAY

public static final int DOWM_TUESDAY
Bit mask for Tuesday

See Also:
Constant Field Values

DOWM_WEDNESDAY

public static final int DOWM_WEDNESDAY
Bit mask for Wednesday

See Also:
Constant Field Values

DOWM_THURSDAY

public static final int DOWM_THURSDAY
Bit mask for Thursday

See Also:
Constant Field Values

DOWM_FRIDAY

public static final int DOWM_FRIDAY
Bit mask for Friday

See Also:
Constant Field Values

DOWM_SATURDAY

public static final int DOWM_SATURDAY
Bit mask for Saturday

See Also:
Constant Field Values

DOWM_WEEKDAYS

public static final int DOWM_WEEKDAYS
Bit mask for Working Days

See Also:
Constant Field Values

DOWM_WEEKENDDAYS

public static final int DOWM_WEEKENDDAYS
Bit mask for Weekend Days

See Also:
Constant Field Values

DOWM_ALLDAYS

public static final int DOWM_ALLDAYS
Bit mask for Working Days

See Also:
Constant Field Values
Constructor Detail

CalendarHelp

public CalendarHelp()
Method Detail

toLong

public static long toLong(java.util.Calendar cal)
Converts a calendar into a long value for compatibility with JDK 1.3

Parameters:
cal - Calendar to convert
Returns:
long value

setFromLong

public static void setFromLong(java.util.Calendar cal,
                               long timeInMillis)
Initializes the calendar with the given UTC timestamp for compatibility with JDK 1.3

Parameters:
cal - the calendar
timeInMillis - UTC timestamp

getDays

public static int getDays(java.util.Calendar date1,
                          java.util.Calendar date2)
This method calculates the number of days between the two dates.

Parameters:
date1 - the first day
date2 - the last day
Returns:
Number of days

isSameDay

public static boolean isSameDay(java.util.Calendar a,
                                java.util.Calendar b)
Checks if both dates are on the same day

Parameters:
a - first date
b - second date
Returns:
true if the days cover the same day

parseDayMask

public static int parseDayMask(java.lang.String dayList)
Parses a semicolon separated Day list and creates a day mask

Parameters:
dayList - Semicolon separated list with day names (Locale.ENGLISH)
Returns:
Day bit mask

parseDay

public static int parseDay(java.lang.String dayName)
Converts a Day Name into a integer value

Parameters:
dayName - The Day Name (Locale.ENGLISH)
Returns:
Day index (as defined in Calendar class)

rollDay

public static int rollDay(int dayOfWeek,
                          int offset)
Rolls the day index by the given offset

Parameters:
dayOfWeek - Starting day index
offset - the offset to roll
Returns:
resulting day index

between

public static boolean between(java.util.Calendar date,
                              java.util.Calendar t1,
                              java.util.Calendar t2)
This method checks if the given date falls between the dates t1 and t2. The resolution for this check is the day - the time will be ignored

Parameters:
date - the date to check
t1 - lower interval boundary
t2 - upper interval boundary
Returns:
returns true when the given date falls into the interval

isWeekEndDay

public static boolean isWeekEndDay(int dayOfWeek)
Checks if the given day is a weekend day

Parameters:
dayOfWeek - the day to check
Returns:
true if this is a weekend day


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.