Class DateTimeUtil

java.lang.Object
de.uplanet.lucy.server.auxiliaries.datetime.DateTimeUtil

@VelocityVariable("DtUtil") @VelocityCallable("singleton") public final class DateTimeUtil extends Object
  • Field Details

    • UTC_ISO_DATE_TIME_FORMAT

      public static final String UTC_ISO_DATE_TIME_FORMAT
      The standard ISO UTC format yyyy-MM-dd'T'HH:mm:ss'Z'.
      See Also:
    • UTC_ISO_DATE_TIME_FORMAT_MILLIS

      public static final String UTC_ISO_DATE_TIME_FORMAT_MILLIS
      The standard ISO UTC format with milliseconds yyyy-MM-dd'T'HH:mm:ss.SSS'Z'.
      See Also:
    • DATE_TIME_FORMAT_1

      public static final String DATE_TIME_FORMAT_1
      The format yyyy-MM-dd HH:mm:ss.
      See Also:
    • DATE_TIME_FORMAT_2

      public static final String DATE_TIME_FORMAT_2
      The format yyyy-MM-dd HH:mm.
      See Also:
    • COMPARATOR_DATE_TIME_SORT_NULL_LOW

      public static final Comparator<Object> COMPARATOR_DATE_TIME_SORT_NULL_LOW
      Compares two date/time objects with millisecond accuracy. null is sorted low.

      The comparator accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers,
      • calendar objects, and
      • null
      as argument types.

    • COMPARATOR_DATE_TIME_SORT_NULL_HIGH

      public static final Comparator<Object> COMPARATOR_DATE_TIME_SORT_NULL_HIGH
      Compares two date/time objects with millisecond accuracy. null is sorted high.

      The comparator accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers,
      • calendar objects, and
      • null
      as argument types.

  • Constructor Details

    • DateTimeUtil

      public DateTimeUtil()
  • Method Details

    • getServerDefaultTimeZone

      public TimeZone getServerDefaultTimeZone()
      Get the default server time zone.
      Returns:
      The default time zone.
    • getTimeZone

      public TimeZone getTimeZone(IUser p_user)
      Get the context time zone from the user, or, if not present, the default server time zone.
      Parameters:
      p_user - The user from which to get the time zone, or null.
    • getTimeZone

      public TimeZone getTimeZone(String p_strTimeZoneId)
      Get the specified time zone.
      Parameters:
      p_strTimeZoneId - The time zone ID, either a full name such as "Europe/Berlin", "America/Los_Angeles", or a custom ID such as "GMT-8:00".
      Returns:
      The default time zone.
    • wrap

      public CalendarAwareDate wrap(Object p_date)
      Wrap the instance in time into a CalendarAwareDate.

      The new object will have an UTC calendar associated for date arithmetics.

      Parameters:
      p_date - An object that represents a date.
      Returns:
      A new date object that represents the same instance in time.
      See Also:
    • wrap

      public CalendarAwareDate wrap(Object p_date, TimeZone p_tz)
      Wrap the instance in time into a CalendarAwareDate.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as the p_date argument.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be associated with the resultant date object.
      Returns:
      A new date object that represents the same instance in time.
      Throws:
      IllegalArgumentException - If p_date is null, or a value holder that does not contain a value, or if p_tz is null.
    • compareNullLow

      public int compareNullLow(Object p_lhs, Object p_rhs)
      Compares two date/time objects with millisecond accuracy. null is sorted low.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers,
      • calendar objects, and
      • null
      as argument types.

      Parameters:
      p_lhs - The left hand side of the comparison.
      p_rhs - The right hand side of the comparison.
      Returns:
      Either 0, or 1, or -1.
    • compareNullHigh

      public int compareNullHigh(Object p_lhs, Object p_rhs)
      Compares two date/time objects with millisecond accuracy. null is sorted high.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers,
      • calendar objects, and
      • null
      as argument types.

      Parameters:
      p_lhs - The left hand side of the comparison.
      p_rhs - The right hand side of the comparison.
      Returns:
      Either 0, or 1, or -1.
    • sortNullLow

      public List<Object> sortNullLow(List<Object> p_list)
      Sort the given list of date/time objects with millisecond accuracy. nulls are sorted low.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers,
      • calendar objects, and
      • null
      as list items.

      Parameters:
      p_list - The list to be sorted.
      Returns:
      The given list.
    • sortNullHigh

      public List<Object> sortNullHigh(List<Object> p_list)
      Sort the given list of date/time objects with millisecond accuracy. nulls are sorted high.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers,
      • calendar objects, and
      • null
      as list items.

      Parameters:
      p_list - The list to be sorted.
      Returns:
      The given list.
    • utcNow

      public CalendarAwareDate utcNow()
      Create a date object with the current date and time.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.4.

      Returns:
      The newly created date object.
    • now

      public CalendarAwareDate now(TimeZone p_tz)
      Create a date object with the current date and time.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.4.

      Parameters:
      p_tz - The time zone.
      Returns:
      The newly created date object.
    • date

      public CalendarAwareDate date(int p_iYear, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The month is set to January, the day is set to 1, the remaining fields are set to 0.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • date

      public CalendarAwareDate date(int p_iYear, int p_iMonth, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The day is set to 1, the remaining fields are set to 0.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • date

      public CalendarAwareDate date(int p_iYear, int p_iMonth, int p_iDay, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The time fields are set to 0.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • date

      public CalendarAwareDate date(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • date

      public CalendarAwareDate date(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, int p_iMinute, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_iMinute - The minute.
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • date

      public CalendarAwareDate date(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, int p_iMinute, int p_iSecond, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_iMinute - The minute.
      p_iSecond - The second.
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • date

      public CalendarAwareDate date(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, int p_iMinute, int p_iSecond, int p_iMillisecond, TimeZone p_tz)
      Create a date object from date fields given in the specified time zone.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.2.1.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_iMinute - The minute.
      p_iSecond - The second.
      p_iMillisecond - The milliseconds.
      p_tz - The time zone to be used.
      Returns:
      The newly created date object.
      Throws:
      IllegalArgumentException - If p_tz is null.
    • utc

      public CalendarAwareDate utc(int p_iYear)
      Create a date object from date fields given in UTC.

      The month is set to January, the day is set to 1, the remaining fields are set to 0.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      Returns:
      The newly created date object.
    • utc

      public CalendarAwareDate utc(int p_iYear, int p_iMonth)
      Create a date object from date fields given in UTC.

      The day is set to 1, the remaining fields are set to 0.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      Returns:
      The newly created date object.
    • utc

      public CalendarAwareDate utc(int p_iYear, int p_iMonth, int p_iDay)
      Create a date object from date fields given in UTC.

      The time fields are set to 0.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      Returns:
      The newly created date object.
    • utc

      public CalendarAwareDate utc(int p_iYear, int p_iMonth, int p_iDay, int p_iHour)
      Create a date object from date fields given in UTC.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      Returns:
      The newly created date object.
    • utc

      public CalendarAwareDate utc(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, int p_iMinute)
      Create a date object from date fields given in UTC.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_iMinute - The minute.
      Returns:
      The newly created date object.
    • utc

      public CalendarAwareDate utc(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, int p_iMinute, int p_iSecond)
      Create a date object from date fields given in UTC.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_iMinute - The minute.
      p_iSecond - The second.
      Returns:
      The newly created date object.
    • utc

      public CalendarAwareDate utc(int p_iYear, int p_iMonth, int p_iDay, int p_iHour, int p_iMinute, int p_iSecond, int p_iMillisecond)
      Create a date object from date fields given in UTC.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.4.3.

      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      p_iHour - The hour of day.
      p_iMinute - The minute.
      p_iSecond - The second.
      p_iMillisecond - The milliseconds.
      Returns:
      The newly created date object.
    • isToday

      public boolean isToday(Object p_obj, TimeZone p_tz)
      Check if the given object references the same year, month, and day as the current date. Hours, minutes, seconds, and milliseconds are ignored.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_obj - An object that references a date.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the given object refers to the the same year, month, and day as the current date, or false otherwise.
      Throws:
      IllegalArgumentException - If the given value is null, or a value holder that does not contain a value.
    • isSameY

      public boolean isSameY(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same year. Months, days, hours, minutes, seconds, and milliseconds are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same year, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isSameYM

      public boolean isSameYM(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same year, and month. Days, hours, minutes, seconds, and milliseconds are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same year, and month, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isSameYMD

      public boolean isSameYMD(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same year, month, and day. Hours, minutes, seconds, and milliseconds are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same year, month, and day, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isSameH

      public boolean isSameH(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same hour. Year, month, day, minutes, seconds, and milliseconds are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same hour, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isSameHM

      public boolean isSameHM(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same hour, and minute. Year, month, day, seconds, and milliseconds are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same hour, and minute, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isSameHMS

      public boolean isSameHMS(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same hour, minute, and second. Year, month, day, and milliseconds are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same hour, minute, and second, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isSameHMSM

      public boolean isSameHMSM(Object p_obj1, Object p_obj2, TimeZone p_tz)
      Check if the given objects reference the same hour, minute, second, and millisecond. Year, month, and day are ignored.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_obj1 - The first object in the comparison.
      p_obj2 - The second object in the comparison.
      p_tz - The time zone where the comparison should take place.
      Returns:
      true if the two objects refer to the the same hour, minute, and second, or false otherwise.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isMonday

      public boolean isMonday(Object p_date, TimeZone p_tz)
    • isTuesday

      public boolean isTuesday(Object p_date, TimeZone p_tz)
    • isWednesday

      public boolean isWednesday(Object p_date, TimeZone p_tz)
    • isThursday

      public boolean isThursday(Object p_date, TimeZone p_tz)
    • isFriday

      public boolean isFriday(Object p_date, TimeZone p_tz)
    • isSaturday

      public boolean isSaturday(Object p_date, TimeZone p_tz)
    • isSunday

      public boolean isSunday(Object p_date, TimeZone p_tz)
    • getDifference

      public Duration getDifference(Object p_lhs, Object p_rhs)
      Get the time difference between the two objects.

      Note that this method does not have any information about a calendar to be used. So differences that span DST switches in a certain calendar might not return the expected result when expressed in days.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_lhs - The left hand side of the difference.
      p_rhs - The right hand side of the difference.
      Returns:
      The difference.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • getDifferenceFromMilliseconds

      public Duration getDifferenceFromMilliseconds(long p_lTime)
      Ctreate a difference object for the given time difference.
      Parameters:
      p_lTime - The time difference in milliseconds.
      Returns:
      The difference.
    • getDifferenceInMilliseconds

      public long getDifferenceInMilliseconds(Object p_lhs, Object p_rhs)
      Get the time difference in milliseconds between the two objects.

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_lhs - The left hand side of the difference.
      p_rhs - The right hand side of the difference.
      Returns:
      The difference in milliseconds.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • getDifferenceInYears

      public int getDifferenceInYears(Object p_lhs, Object p_rhs, TimeZone p_tz)
      Get the time difference in full years between the two objects.

      difference = left hand side - right hand side

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_lhs - The left hand side of the difference.
      p_rhs - The right hand side of the difference.
      p_tz - The time zone to be used to calculate the difference.
      Returns:
      The difference in years.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • getDifferenceInMonths

      public int getDifferenceInMonths(Object p_lhs, Object p_rhs, TimeZone p_tz)
      Get the time difference in full months between the two objects.

      difference = left hand side - right hand side

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_lhs - The left hand side of the difference.
      p_rhs - The right hand side of the difference.
      p_tz - The time zone to be used to calculate the difference.
      Returns:
      The difference in months.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • getDifferenceInDays

      public int getDifferenceInDays(Object p_lhs, Object p_rhs, TimeZone p_tz)
      Get the time difference in full days between the two objects.

      difference = left hand side - right hand side

      The method accepts mixed

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument types.

      Parameters:
      p_lhs - The left hand side of the difference.
      p_rhs - The right hand side of the difference.
      p_tz - The time zone to be used to calculate the difference.
      Returns:
      The difference in days.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value.
    • isLeapYear

      public boolean isLeapYear(int p_iYear)
      Determines if the given year is a leap year in the Gregorian Calendar.
      Parameters:
      p_iYear - The year.
      Returns:
      true if the given year is a leap year, or false otherwise.
    • getLunationNumber

      public long getLunationNumber(Object p_date)
      Get the Brown Lunation Number.

      See Wikipedia: Lunation Number

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents the date for which the lunation number should be calculated.
      Returns:
      The Brown Lunation Number.
    • getMeeusLunationNumber

      public long getMeeusLunationNumber(Object p_date)
      Get the Meeus Lunation Number.

      See Wikipedia: Lunation Number

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents the date for which the lunation number should be calculated.
      Returns:
      The Brown Lunation Number.
    • getPhaseOfTheMoon

      public double getPhaseOfTheMoon(Object p_date)
      Get the phase of the moon.

      The result is a value greater or equal zero, and less than one, representing the phase of the moon from new moon to new moon.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents the date for which the phase of the moon should be calculated.
      Returns:
      A value greater or equal zero, and less than one.
    • getISO8601WeekNumber

      public int getISO8601WeekNumber(int p_iYear, int p_iMonth, int p_iDay)
      Get the week number as defined in DIN 1355/ISO 8601.
      Parameters:
      p_iYear - The year.
      p_iMonth - The month (0 for January, ...).
      p_iDay - The day of month.
      Returns:
      The week number as defined in DIN 1355/ISO 8601.
    • getISO8601WeekNumber

      public int getISO8601WeekNumber(Object p_date, TimeZone p_tz)
      Get the week number as defined in DIN 1355/ISO 8601.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as the p_date argument.

      Returns:
      The week number as defined in DIN 1355/ISO 8601.
      Throws:
      IllegalArgumentException - If a given value is null, or a value holder that does not contain a value, or if p_tz is null.
    • getISO8601WeekStart

      public CalendarAwareDate getISO8601WeekStart(int p_iYear, int p_iWeek, TimeZone p_tz)
      Get the beginning of the week as defined in ISO 8601.
      Parameters:
      p_iYear - The year.
      p_iWeek - The week (1 is the first week of the year, 2 the second ..., 0 ist the last week of the year before, ...).
      p_tz - The time zone.
      Returns:
      The beginning of the week.
    • getQuarter

      public int getQuarter(Object p_date, TimeZone p_tz)
      Get the quarter that contains the given date.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone.
      Returns:
      The quarter, i.e. either 1, 2, 3, or 4.
      Since:
      Intrexx 7.0.
    • getStartOfQuarter

      public CalendarAwareDate getStartOfQuarter(Object p_date, TimeZone p_tz)
      Get the start of the quarter that contains the given date. Hour, minute, seconds, and fractions of seconds are set to zero.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone.
      Returns:
      The start of the quarter as both a java.sql.Timestamp and as a IDateTimeValueHolder.
      Since:
      Intrexx 7.0.
    • getStartOfWeek

      public CalendarAwareDate getStartOfWeek(Object p_obj, int p_iFirstDayOfWeek, TimeZone p_tz)
      Get the start of the week that contains the given date. Hour, minute, seconds, and fractions of seconds are set to zero.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The date, either as an integer, or date, or IValueHolder.
      p_iFirstDayOfWeek - The day the weeks starts with (1 for Sunday, 2 for Monday, ..., 7 for Saturday).
      p_tz - The time zone.
      Returns:
      The date that represents the requested start of the week as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getShroveMondayDate

      public CalendarAwareDate getShroveMondayDate(Object p_obj, TimeZone p_tz)
      Get the Shrove Monday (Rosenmontag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Shrove Monday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getAshWednesdayDate

      public CalendarAwareDate getAshWednesdayDate(Object p_obj, TimeZone p_tz)
      Get the Ash Wednesday (Aschermittwoch) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Ash Wednesday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getMaundyThursdayDate

      public CalendarAwareDate getMaundyThursdayDate(Object p_obj, TimeZone p_tz)
      Get the Maundy Thursday (Gründonnerstag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Maundy Thursday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getGoodFridayDate

      public CalendarAwareDate getGoodFridayDate(Object p_obj, TimeZone p_tz)
      Get the Good Friday (Karfreitag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Good Friday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getEasterDate

      public CalendarAwareDate getEasterDate(Object p_obj, TimeZone p_tz)
      Get the Easter (Ostersonntag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Easter date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getEasterMondayDate

      public CalendarAwareDate getEasterMondayDate(Object p_obj, TimeZone p_tz)
      Get the Easter Monday (Ostermontag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Easter Monday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getAscensionDate

      public CalendarAwareDate getAscensionDate(Object p_obj, TimeZone p_tz)
      Get the Ascension Day (Christi Himmelfahrt) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Ascension Day date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getWhitSundayDate

      public CalendarAwareDate getWhitSundayDate(Object p_obj, TimeZone p_tz)
      Get the Whit Sunday (Pfingstsonntag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Whit Sunday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getWhitMondayDate

      public CalendarAwareDate getWhitMondayDate(Object p_obj, TimeZone p_tz)
      Get the Whit Monday (Pfingstmontag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Whit Monday date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getPentecostDate

      public CalendarAwareDate getPentecostDate(Object p_obj, TimeZone p_tz)
      Get the Pentecost date (Pfingstsonntag) in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Pentecost date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getCorpusChristiDate

      public CalendarAwareDate getCorpusChristiDate(Object p_obj, TimeZone p_tz)
      Get the Corpus Christi (Fronleichnam) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Corpus Christi date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • getPenanceDayDate

      public CalendarAwareDate getPenanceDayDate(Object p_obj, TimeZone p_tz)
      Get the Penance Day (Buß- und Bettag) date in the given year.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_obj - The year, either as an integer, or date, or IValueHolder.
      p_tz - The time zone.
      Returns:
      The Penance Day date as both a java.sql.Timestamp and as a IDateTimeValueHolder.
    • dateToISOString

      public String dateToISOString(Object p_date)
      Get a string value that represents the instance in time represented by the given date object, without milliseconds.

      The format of the string is yyyy-MM-dd'T'HH:mm:ss'Z'. The time zone is always UTC, as denoted by the suffix Z.
      See also the ECMAScript Language Specification, ECMA-262, 15.9.1.15 and 15.9.5.43.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      Returns:
      The string value.
      Throws:
      IllegalArgumentException - If p_date is null.
    • dateToISOStringWithMilliseconds

      public String dateToISOStringWithMilliseconds(Object p_date)
      Get a string value that represents the instance in time represented by the given date object, including milliseconds

      The format of the string is yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. The time zone is always UTC, as denoted by the suffix Z.
      See also the ECMAScript Language Specification, ECMA-262, 15.9.1.15 and 15.9.5.43.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      Returns:
      The string value.
      Throws:
      IllegalArgumentException - If p_date is null.
    • getDayOfWeekName

      public String getDayOfWeekName(Number p_num)
      Get the day of week name by its number (1 = Sunday, ..., 7 = Saturday).
      Parameters:
      p_num - The day of week number.
      Returns:
      The name of the given day of week.
      Since:
      Intrexx 7.0.
    • getDayOfWeekName

      public String getDayOfWeekName(Number p_num, String p_strLocaleId)
      Get the day of week name by its number (1 = Sunday, ..., 7 = Saturday).
      Parameters:
      p_num - The day of week number.
      p_strLocaleId - The locale to be used.
      Returns:
      The name of the given day of week.
      Since:
      Intrexx 7.0.
    • getDayOfWeekShortName

      public String getDayOfWeekShortName(Number p_num)
      Get the day of week short name by its number (1 = Sun, ..., 7 = Sat).
      Parameters:
      p_num - The day of week number.
      Returns:
      The short name of the given day of week.
      Since:
      Intrexx 7.0.
    • getDayOfWeekShortName

      public String getDayOfWeekShortName(Number p_num, String p_strLocaleId)
      Get the day of week short name by its number (1 = Sun, ..., 7 = Sat).
      Parameters:
      p_num - The day of week number.
      p_strLocaleId - The locale to be used.
      Returns:
      The short name of the given day of week.
      Since:
      Intrexx 7.0.
    • getDayOfWeekName

      public String getDayOfWeekName(Object p_date, TimeZone p_tz)
      Get the name of the given day of week.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      Returns:
      The name of the given day of week.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getDayOfWeekName

      public String getDayOfWeekName(Object p_date, TimeZone p_tz, String p_strLocaleId)
      Get the name of the given day of week.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The name of the given day of week.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getDayOfWeekShortName

      public String getDayOfWeekShortName(Object p_date, TimeZone p_tz)
      Get the short name of the given day of week.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      Returns:
      The short name of the given day of week.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getDayOfWeekShortName

      public String getDayOfWeekShortName(Object p_date, TimeZone p_tz, String p_strLocaleId)
      Get the short name of the given day of week.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The short name of the given day of week.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getMonthName

      public String getMonthName(Number p_num)
      Get the month name by its number (0 = January, ..., 11 = December).
      Parameters:
      p_num - The month number which can be any integer value.
      Returns:
      The month name.
      Since:
      Intrexx 7.0.
    • getMonthName

      public String getMonthName(Number p_num, String p_strLocaleId)
      Get the month name by its number (0 = January, ..., 11 = December).
      Parameters:
      p_num - The month number which can be any integer value.
      p_strLocaleId - The locale to be used.
      Returns:
      The month name.
      Since:
      Intrexx 7.0.
    • getMonthShortName

      public String getMonthShortName(Number p_num)
      Get the month short name by its number (0 = Jan, ..., 11 = Dec).
      Parameters:
      p_num - The month number which can be any integer value.
      Returns:
      The month short name.
      Since:
      Intrexx 7.0.
    • getMonthShortName

      public String getMonthShortName(Number p_num, String p_strLocaleId)
      Get the month short name by its number (0 = Jan, ..., 11 = Dec).
      Parameters:
      p_num - The month number which can be any integer value.
      p_strLocaleId - The locale to be used.
      Returns:
      The month short name.
      Since:
      Intrexx 7.0.
    • getMonthName

      public String getMonthName(Object p_date, TimeZone p_tz)
      Get the name of the given month.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      Returns:
      The name of the given month.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getMonthName

      public String getMonthName(Object p_date, TimeZone p_tz, String p_strLocaleId)
      Get the name of the given month.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The name of the given month.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getMonthShortName

      public String getMonthShortName(Object p_date, TimeZone p_tz)
      Get the short name of the given month.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      Returns:
      The short name of the given month.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • getMonthShortName

      public String getMonthShortName(Object p_date, TimeZone p_tz, String p_strLocaleId)
      Get the short name of the given month.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The short name of the given month.
      Throws:
      IllegalArgumentException - If p_date or p_tz is null.
      Since:
      Intrexx 7.0.
    • formatDate

      public String formatDate(String p_strFormat, Object p_date, TimeZone p_tz)
      Format a date according to the given simple date format.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      Returns:
      The formatted date.
      Throws:
      IllegalArgumentException - If p_strFormat, or p_date or p_tz is null.
    • formatDate

      public String formatDate(String p_strFormat, Object p_date, TimeZone p_tz, String p_strLocaleId)
      Format a date according to the given simple date format.

      The method accepts

      • date objects,
      • timestamp objects,
      • value holders,
      • numbers, and
      • calendar objects
      as argument type.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_date - An object that represents a date.
      p_tz - The time zone to be used.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The formatted date.
      Throws:
      IllegalArgumentException - If p_strFormat, or p_date or p_tz is null.
    • isoStringToDate

      public CalendarAwareDate isoStringToDate(String p_strDate)
      Parse a string of the form yyyy-MM-dd'T'HH:mm:ss'Z' or yyyy-MM-dd'T'HH:mm:ss.SSS'Z' as a date.

      The new object will have an UTC calendar associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.1.15.

      Parameters:
      p_strDate - The string that represents the date.
      Returns:
      The parsed date, or null if an error occurred while parsing.
    • isoStringToDate

      public CalendarAwareDate isoStringToDate(String p_strDate, TimeZone p_tz)
      Parse a string of the form yyyy-MM-dd'T'HH:mm:ss'Z' or yyyy-MM-dd'T'HH:mm:ss.SSS'Z' as a date.

      The new date object will have a calendar with the specified time zone associated for date arithmetics.

      See also the ECMAScript Language Specification, ECMA-262, 15.9.1.15.

      Parameters:
      p_strDate - The string that represents the date.
      p_tz - The time zone to be associated with the resultant date object.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strDate is null or empty.
    • parseDate

      public CalendarAwareDate parseDate(String p_strFormat, String p_strDate, TimeZone p_tzParse)
      Parse a string with the given format as a date in the given time zone.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_tzParse - The time zone used to parse the string.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty, or if the given time zone is null.
      Since:
      Intrexx 6.0. The method with the same name and signature in previous versions had different semantics.
    • parseDate

      public CalendarAwareDate parseDate(String p_strFormat, String p_strDate, TimeZone p_tzParse, String p_strLocaleId)
      Parse a string with the given format as a date in the given time zone.

      The new object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_tzParse - The time zone used to parse the string.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty, or if the given time zone is null.
      Since:
      Intrexx 7.0.
    • parseDate

      public CalendarAwareDate parseDate(String p_strFormat, String p_strDate, TimeZone p_tzParse, TimeZone p_tzAssoc)
      Parse a string with the given format as a date in the given time zone.

      The new date object will have a calendar with the time zone given as the fourth parameter associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_tzParse - The time zone used to parse the string.
      p_tzAssoc - The time zone to be associated with the resultant date object.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty, or if one the given time zones is null.
      Since:
      Intrexx 6.0.
    • parseDate

      public CalendarAwareDate parseDate(String p_strFormat, String p_strDate, TimeZone p_tzParse, TimeZone p_tzAssoc, String p_strLocaleId)
      Parse a string with the given format as a date in the given time zone.

      The new date object will have a calendar with the time zone given as the fourth parameter associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_tzParse - The time zone used to parse the string.
      p_tzAssoc - The time zone to be associated with the resultant date object.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty, or if one the given time zones is null.
      Since:
      Intrexx 7.0.
    • parseUTCDate

      public CalendarAwareDate parseUTCDate(String p_strFormat, String p_strDate)
      Parse a string with the given format as a date in the UTC time zone.

      The new date object will have a calendar with the UTC time zone associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty.
      Since:
      Intrexx 6.0.
    • parseUTCDate

      public CalendarAwareDate parseUTCDate(String p_strFormat, String p_strDate, String p_strLocaleId)
      Parse a string with the given format as a date in the UTC time zone.

      The new date object will have a calendar with the UTC time zone associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty.
      Since:
      Intrexx 7.0.
    • parseUTCDate

      public CalendarAwareDate parseUTCDate(String p_strFormat, String p_strDate, TimeZone p_tzAssoc)
      Parse a string with the given format as a date in the UTC time zone.

      The new date object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_tzAssoc - The time zone to be associated with the resultant date object.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty, or if the given time zone is null.
      Since:
      Intrexx 6.0.
    • parseUTCDate

      public CalendarAwareDate parseUTCDate(String p_strFormat, String p_strDate, TimeZone p_tzAssoc, String p_strLocaleId)
      Parse a string with the given format as a date in the UTC time zone.

      The new date object will have a calendar with the specified time zone associated for date arithmetics.

      Parameters:
      p_strFormat - The format string (see SimpleDateFormat).
      p_strDate - The string to be parsed.
      p_tzAssoc - The time zone to be associated with the resultant date object.
      p_strLocaleId - The ID (language tag) of the locale to be used.
      Returns:
      The parsed date, or null if an error occurred while parsing.
      Throws:
      IllegalArgumentException - If p_strFormat or p_strDate is null or empty, or if the given time zone is null.
      Since:
      Intrexx 7.0.