Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.compoze.util
Class CalendarUtility

    java.lang.Object
      com.compoze.util.CalendarUtility

public class CalendarUtility
extends java.lang.Object

This class contains utility methods for manipulating calendars and related items.

Nested Class Summary
`static class` | `CalendarUtility.IntStringPair` This class holds an integer key and a String value, and is used to return the results of enumerating the days and months.

Constructor Summary
`CalendarUtility()`

Method Summary
`static java.util.TimeZone[]` | `getCommonTimeZones()` Gets a list of most common java timezones, these have an approximate mapping to the windows timezones.
`static java.lang.String` | `getDayByNumber(int iDay)` Gets the localized string for a day.
`static java.lang.String` | `getDayByNumber(int iDay, int iFieldWidth)` Gets the localized string for a day.
`static java.lang.String` | `getDayByNumber(int iDay, int iFieldWidth, java.util.Calendar cal, java.util.Locale locale)` Gets the localized string for a day.
`static java.lang.String` | `getDayByNumber(int iDay, int iFieldWidth, java.util.Locale locale)` Gets the localized string for a day.
`static java.lang.String` | `getDayByNumber(int iDay, java.util.Locale locale)` Gets the localized string for a day.
`static java.util.Collection` | `getDays()` Returns a collection of IntStringPair objects representing the days.
`static java.util.Collection` | `getDays(int iFieldWidth)` Returns a collection of IntStringPair objects representing the days.
`static java.util.Collection` | `getDays(int iFieldWidth, java.util.Calendar cal, java.util.Locale locale)` Returns a collection of IntStringPair objects representing the days.
`static java.util.Collection` | `getDays(int iFieldWidth, java.util.Locale locale)` Returns a collection of IntStringPair objects representing the days.
`static java.util.Collection` | `getDays(java.util.Locale locale)` Returns a collection of IntStringPair objects representing the days.
`static java.util.Date` | `getFirstWorkDayOfWeek(java.util.Date givenDate)` Gets the first work day of the week the given date occurs during.
`static java.util.Date` | `getFirstWorkDayOfWeek(java.util.Date givenDate, java.util.Calendar cal)` Gets the first work day of the week the specified date occurs during.
`static java.util.Date` | `getLastWorkDayOfWeek(java.util.Date givenDate)` Gets the last work day of the week the specified date occurs during.
`static java.util.Date` | `getLastWorkDayOfWeek(java.util.Date givenDate, java.util.Calendar cal)` Gets the last work day of the week the specified date occurs during.
`static java.lang.String` | `getMonthByNumber(int iMonth)` Gets the localized string for a month.
`static java.lang.String` | `getMonthByNumber(int iMonth, int iFieldWidth)` Gets the localized string for a month.
`static java.lang.String` | `getMonthByNumber(int iMonth, int iFieldWidth, java.util.Calendar cal, java.util.Locale locale)` Gets the localized string for a month.
`static java.lang.String` | `getMonthByNumber(int iMonth, int iFieldWidth, java.util.Locale locale)` Gets the localized string for a month.
`static java.lang.String` | `getMonthByNumber(int iMonth, java.util.Locale locale)` Gets the localized string for a month.
`static java.util.Collection` | `getMonths()` Returns a collection of IntStringPair objects representing the months.
`static java.util.Collection` | `getMonths(int iFieldWidth)` Returns a collection of IntStringPair objects representing the months.
`static java.util.Collection` | `getMonths(int iFieldWidth, java.util.Calendar cal, java.util.Locale locale)` Returns a collection of IntStringPair objects representing the months.
`static java.util.Collection` | `getMonths(int iFieldWidth, java.util.Locale locale)` Returns a collection of IntStringPair objects representing the months.
`static java.util.Collection` | `getMonths(java.util.Locale locale)` Returns a collection of IntStringPair objects representing the months.
`static void` | `main(java.lang.String[] args)` Exerciser.
`static java.util.Date` | `roundDate(java.util.Date date)` Rounds a date to the nearest midnight.
`static void` | `setDefaultLocale(java.util.Locale locale)` Sets the default locale used for all calendar operations.
`static java.util.Date` | `truncateDate(java.util.Date date, int iField)` Truncates a date to the resolution of the given calendar field.
`static java.util.Date` | `truncateDate(java.util.Date date, int iField, java.util.Calendar cal)` Truncates a date to the resolution of the given calendar field.
`static java.util.Date` | `truncateDate(java.util.Date date, int iField, java.util.Locale locale)` Truncates a date to the resolution of the given calendar field.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CalendarUtility

    public CalendarUtility()

Method Detail

### setDefaultLocale

    public static void setDefaultLocale(java.util.Locale locale)

  Sets the default locale used for all calendar operations.

  Parameters:
    `locale` - new default locale

### getCommonTimeZones

    public static java.util.TimeZone[] getCommonTimeZones()

  Gets a list of most common java timezones, these have an approximate mapping to the windows timezones.

  Returns:
    an array of common Java time zones

### getMonthByNumber

    public static java.lang.String getMonthByNumber(int iMonth)

  Gets the localized string for a month.

  Parameters:
    `iMonth` - month number (0=Jan)
  Returns:
    localized string for a month

### getMonthByNumber

    public static java.lang.String getMonthByNumber(int iMonth,
                                                    java.util.Locale locale)

  Gets the localized string for a month.

  Parameters:
    `iMonth` - month number (0=Jan)
    `locale` - locale to use
  Returns:
    localized string for a month

### getMonthByNumber

    public static java.lang.String getMonthByNumber(int iMonth,
                                                    int iFieldWidth)

  Gets the localized string for a month.

  Parameters:
    `iMonth` - month number (0=Jan)
    `iFieldWidth` - width of month field
  Returns:
    localized string for a month

### getMonthByNumber

    public static java.lang.String getMonthByNumber(int iMonth,
                                                    int iFieldWidth,
                                                    java.util.Locale locale)

  Gets the localized string for a month.

  Parameters:
    `iMonth` - month number (0=Jan)
    `iFieldWidth` - width of month field
    `locale` - locale to use
  Returns:
    localized string for a month

### getMonthByNumber

    public static java.lang.String getMonthByNumber(int iMonth,
                                                    int iFieldWidth,
                                                    java.util.Calendar cal,
                                                    java.util.Locale locale)

  Gets the localized string for a month.

  Parameters:
    `iMonth` - month number (0=Jan)
    `iFieldWidth` - width of month field
    `cal` - calendar to use
    `locale` - locale to use
  Returns:
    localized string for a month

### getDayByNumber

    public static java.lang.String getDayByNumber(int iDay)

  Gets the localized string for a day.

  Parameters:
    `iDay` - day number (1=Sunday)
  Returns:
    localized string for a day

### getDayByNumber

    public static java.lang.String getDayByNumber(int iDay,
                                                  java.util.Locale locale)

  Gets the localized string for a day.

  Parameters:
    `iDay` - day number (1=Sunday)
    `locale` - locale to use
  Returns:
    localized string for a day

### getDayByNumber

    public static java.lang.String getDayByNumber(int iDay,
                                                  int iFieldWidth)

  Gets the localized string for a day.

  Parameters:
    `iDay` - day number (1=Sunday)
    `iFieldWidth` - width of day field
  Returns:
    localized string for a day

### getDayByNumber

    public static java.lang.String getDayByNumber(int iDay,
                                                  int iFieldWidth,
                                                  java.util.Locale locale)

  Gets the localized string for a day.

  Parameters:
    `iDay` - day number (1=Sunday)
    `iFieldWidth` - width of day field
    `locale` - locale to use
  Returns:
    localized string for a day

### getDayByNumber

    public static java.lang.String getDayByNumber(int iDay,
                                                  int iFieldWidth,
                                                  java.util.Calendar cal,
                                                  java.util.Locale locale)

  Gets the localized string for a day.

  Parameters:
    `iDay` - day number (1=Sunday)
    `iFieldWidth` - width of day field
    `cal` - calendar to use
    `locale` - locale to use
  Returns:
    localized string for a day

### getMonths

    public static java.util.Collection getMonths()

  Returns a collection of IntStringPair objects representing the months. The key is the month number and the value of the month String.

  Returns:
    collection of IntStringPair objects representing the months

### getMonths

    public static java.util.Collection getMonths(java.util.Locale locale)

  Returns a collection of IntStringPair objects representing the months. The key is the month number and the value of the month String.

  Parameters:
    `locale` - the locale to use
  Returns:
    collection of IntStringPair objects representing the months

### getMonths

    public static java.util.Collection getMonths(int iFieldWidth)

  Returns a collection of IntStringPair objects representing the months. The key is the month number and the value of the month String.

  Parameters:
    `iFieldWidth` - width of month field
  Returns:
    collection of IntStringPair objects representing the months

### getMonths

    public static java.util.Collection getMonths(int iFieldWidth,
                                                 java.util.Locale locale)

  Returns a collection of IntStringPair objects representing the months. The key is the month number and the value of the month String.

  Parameters:
    `iFieldWidth` - width of month field
    `locale` - the locale to use
  Returns:
    collection of IntStringPair objects representing the months

### getMonths

    public static java.util.Collection getMonths(int iFieldWidth,
                                                 java.util.Calendar cal,
                                                 java.util.Locale locale)

  Returns a collection of IntStringPair objects representing the months. The key is the month number and the value of the month String.

  Parameters:
    `iFieldWidth` - width of month field
    `cal` - the calendar to use
    `locale` - the locale to use
  Returns:
    collection of IntStringPair objects representing the months

### getDays

    public static java.util.Collection getDays()

  Returns a collection of IntStringPair objects representing the days. The key is the day number and the value of the day String.

  Returns:
    collection of IntStringPair objects representing the days

### getDays

    public static java.util.Collection getDays(java.util.Locale locale)

  Returns a collection of IntStringPair objects representing the days. The key is the day number and the value of the day String.

  Parameters:
    `locale` - the locale to use
  Returns:
    collection of IntStringPair objects representing the days

### getDays

    public static java.util.Collection getDays(int iFieldWidth)

  Returns a collection of IntStringPair objects representing the days. The key is the day number and the value of the day String.

  Parameters:
    `iFieldWidth` - width of day field
  Returns:
    collection of IntStringPair objects representing the days

### getDays

    public static java.util.Collection getDays(int iFieldWidth,
                                               java.util.Locale locale)

  Returns a collection of IntStringPair objects representing the days. The key is the day number and the value of the day String.

  Parameters:
    `iFieldWidth` - width of day field
    `locale` - the locale to use
  Returns:
    collection of IntStringPair objects representing the days

### getDays

    public static java.util.Collection getDays(int iFieldWidth,
                                               java.util.Calendar cal,
                                               java.util.Locale locale)

  Returns a collection of IntStringPair objects representing the days. The key is the day number and the value of the day String.

  Parameters:
    `iFieldWidth` - width of day field
    `locale` - the locale to use
  Returns:
    collection of IntStringPair objects representing the days

### getFirstWorkDayOfWeek

    public static java.util.Date getFirstWorkDayOfWeek(java.util.Date givenDate)

  Gets the first work day of the week the given date occurs during. The first work day of the week is Monday.

  Parameters:
    `givenDate` - the date
  Returns:
    the date of the first work day of the week

### getFirstWorkDayOfWeek

    public static java.util.Date getFirstWorkDayOfWeek(java.util.Date givenDate,
                                                       java.util.Calendar cal)

  Gets the first work day of the week the specified date occurs during. The first work day of the week is Monday.

  Parameters:
    `givenDate` - the date
    `cal` - the calendar to use
  Returns:
    the date of the first work day of the week

### getLastWorkDayOfWeek

    public static java.util.Date getLastWorkDayOfWeek(java.util.Date givenDate)

  Gets the last work day of the week the specified date occurs during. The last work day of the week is Friday.

  Parameters:
    `givenDate` - the date
  Returns:
    the date of the last work day of the week

### getLastWorkDayOfWeek

    public static java.util.Date getLastWorkDayOfWeek(java.util.Date givenDate,
                                                      java.util.Calendar cal)

  Gets the last work day of the week the specified date occurs during. The last work day of the week is Friday.

  Parameters:
    `givenDate` - the date
    `cal` - the calendar to use
  Returns:
    the date of the last work day of the week

### truncateDate

    public static java.util.Date truncateDate(java.util.Date date,
                                              int iField)

  Truncates a date to the resolution of the given calendar field. The remaining less significant fields will be set to their minimum value.

  Parameters:
    `date` - date to round
    `iField` - the calendar field (valid fields are YEAR, MONTH, DATE, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND, and MILLISECOND)- fields less significant than this will be set to their minimum value
  Returns:
    the rounded date
  See Also:
    `Calendar`

### truncateDate

    public static java.util.Date truncateDate(java.util.Date date,
                                              int iField,
                                              java.util.Locale locale)

  Truncates a date to the resolution of the given calendar field. The remaining less significant fields will be set to their minimum value.

  Parameters:
    `date` - date to round
    `iField` - the calendar field (valid fields are YEAR, MONTH, DATE, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND, and MILLISECOND)- fields less significant than this will be set to their minimum value
    `locale` - the locale to use
  Returns:
    the rounded date
  See Also:
    `Calendar`

### truncateDate

    public static java.util.Date truncateDate(java.util.Date date,
                                              int iField,
                                              java.util.Calendar cal)

  Truncates a date to the resolution of the given calendar field. The remaining less significant fields will be set to their minimum value.

  Parameters:
    `date` - date to round
    `iField` - the calendar field (valid fields are YEAR, MONTH, DATE, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND, and MILLISECOND)- fields less significant than this will be set to their minimum value
    `cal` - the calendar to use
  Returns:
    the rounded date
  See Also:
    `Calendar`

### roundDate

    public static java.util.Date roundDate(java.util.Date date)

  Rounds a date to the nearest midnight.

  Parameters:
    `date` - date to round
  Returns:
    the rounded date
  See Also:
    `Calendar`

### main

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

  Exerciser.

  Parameters:
    `args` - arguments (none taken)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.