public class CalUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ANSI_C_ASCTIME
ANSI C's asctime() format: EEE MMM d HH:mm:ss yyyy
|
static int |
DATE
Date format as set in the configuration
|
static int |
DATE_TIME
Date and time format as set in the configuration
|
static int |
DATE_TIME_SEC
date format : yyyy-MM-dd HH:mm:ss
|
static int |
DATE_TIME_SEC_DIGITS
date format : yyyyMMddHHmmss
|
static int |
DATE_TIME_WITHOUT_ZONE
DATE_TIME without zone info |
static int |
DAYS |
static int |
HOURS |
static int |
ISO
Date format ISO 8601: yyyy-MM-dd'T'HH:mm:ss'Z'
|
static int |
LOG_DATE
Date format for log output: yyyy-MM-dd HH:mm:ss.SSS
|
static long |
MILLISPERDAY
Number of milliseconds per day
|
static int |
MINUTES |
static int |
RFC1036
Date format RFC1036: EEEEEEEEE, dd-MMM-yy HH:mm:ss z
|
static int |
RFC1123
Date format RFC1123: EEE, dd MMM yyyy HH:mm:ss z
|
static int |
SECONDS
TimeInterval Reporing & Time Managment
|
static java.lang.String[] |
SHORT_UNIT_NAMES
short and normal names for TimeUnits
|
static long[] |
UNIT_FACTORS
the Unit Factorys
|
static java.lang.String[] |
UNIT_NAMES |
static int |
WEEK |
static int |
XML_DATE
xml date format: yyyy-MM-dd
|
static int |
XML_DATE_UTC
xml date format: yyyy-MM-dd'Z'
|
static long |
YEAR_THOUSAND
the time value of the date object of date January 1, 1000
|
Modifier and Type | Method and Description |
---|---|
static java.util.Date |
addWorkdays(java.util.Date d1,
int days)
adds the specified amount of workdays to the given date
|
static boolean |
areHolidaysConfigured() |
static void |
deleteTimeInfoUntil(com.ibm.icu.util.Calendar cal,
int field)
Set the time information to 0 starting at the given field, for example hour
|
static int |
easterDay(int year)
calculates the day of the easter-sunday for the given year
|
static com.ibm.icu.util.Calendar |
getCalendar() |
static com.ibm.icu.util.Calendar |
getCalendar(java.util.Locale loc) |
static com.ibm.icu.util.Calendar |
getCalendar(java.util.Locale loc,
java.util.TimeZone tz)
Returns a calendar instance.
|
static com.ibm.icu.util.Calendar |
getCalendar(java.util.TimeZone tz) |
static com.ibm.icu.text.DateFormatSymbols |
getDateFormatSymbols()
Returns a
DateFormatSymbols instance for the current ThreadContext.getThreadLocale() |
static com.ibm.icu.text.DateFormatSymbols |
getDateFormatSymbols(com.ibm.icu.util.Calendar calendar,
java.util.Locale loc)
Returns a
DateFormatSymbols instance for the specified Locale
and Calendar if Calendar is null getCalendar() is usedif Locale is null Locale.getDefault() is used |
static com.ibm.icu.text.DateFormatSymbols |
getDateFormatSymbols(java.util.Locale loc) |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(int type)
Returns a thread save DateFormat object for the given format.
|
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(int type,
java.util.Locale loc)
Get local specific instance of predefined formatter types
|
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(int type,
java.util.Locale locale,
java.util.TimeZone timezone)
get the localized
SimpleDateFormat with the pattern specified by type
if the given type has a fixed locale / timezone
the given locale / timezone is ignored |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(int type,
java.util.Locale locale,
java.util.TimeZone timezone,
com.ibm.icu.util.Calendar cal) |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(int type,
java.util.TimeZone tz) |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(java.lang.String pattern) |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.Locale loc) |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.Locale locale,
java.util.TimeZone timezone)
get a
SimpleDateFormat instance for the pattern/locale/timezone |
static com.ibm.icu.text.SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.TimeZone tz) |
static java.lang.String |
getIntervalInUnits(long interval)
Format a time interval.
|
static java.lang.String |
getIntervalInUnits(long interval,
int maxunit) |
static java.lang.String |
getIntervalInUnits(long interval,
int maxunit,
int minunit) |
static java.lang.String |
getIntervalInUnits(long interval,
int maxunit,
int minunit,
java.lang.String[] unitNames) |
static java.lang.String |
getIntervalInUnits(long interval,
int maxunit,
java.lang.String[] unitNames)
Returns a String representation of a TimeIntervall
|
static java.lang.String |
getIntervalInUnits(long interval,
java.lang.String maxunit)
Returns a String representation of a TimeIntervall using the short names of timeunits
|
static java.lang.String |
getIntervalInUnits(long interval,
java.lang.String maxunit,
java.lang.String minunit) |
static java.util.Calendar |
getJavaCalendar(com.ibm.icu.util.Calendar icuCalendar) |
static int |
getUnitIntFromString(java.lang.String unit) |
static boolean |
isBetween(java.util.Date date,
java.util.Date start,
java.util.Date end)
returns true if the passed date is not before start and not after end.
|
static java.lang.String |
isHoliday(com.ibm.icu.util.Calendar c)
Returns null or the name of the holiday for the given day
|
static boolean |
isNonWorkingDay(int day_of_week)
this method checky configured workind days of week only.
|
static boolean |
isWorkingDay(com.ibm.icu.util.Calendar c)
checks if a given date is defined as working day
|
static java.util.Date |
parseDate(int type,
java.lang.String dateString)
parse a date from a string with the specified formatter
|
static java.util.Date |
parseDate(java.lang.String s)
Parse a date from a string.
|
static java.util.Date |
parseDateEndDay(java.lang.String s)
Parses the date sets the time to 23:59:59:999.
|
static com.ibm.icu.util.TimeZone |
parseTimeZone(java.util.TimeZone tz) |
static void |
reconfigure() |
static void |
setDateFormatter(int type,
com.ibm.icu.text.SimpleDateFormat df) |
static java.lang.String |
showDate(int type,
java.util.Locale locale,
java.util.TimeZone timezone,
java.lang.Object d) |
static java.lang.String |
showDate(int type,
java.lang.Object d) |
static java.lang.String |
showDate(java.lang.Object d)
Show the date using the default formatter.
|
static java.lang.String |
showDate(java.lang.String pattern,
java.util.Locale locale,
java.util.TimeZone timeZone,
java.lang.Object d) |
static java.lang.String |
showDate(java.lang.String pattern,
java.lang.Object d) |
static java.lang.String |
showDateTime(java.lang.Object d)
Show the date and time using the default formatter.
|
static java.lang.String |
showDateTimeSeconds(java.lang.Object d)
Show the date and time in the form yyyy-MM-dd HH:mm:ss.
|
static int |
thisYear()
Return the current year.
|
static java.util.Date |
toBeginDay(java.util.Date date)
returns the date set to 00:00:00:00
|
static java.util.Date |
toEndDay(java.util.Date date)
returns a date set to 23:59:59:999
|
static int |
workDaysBetween(java.util.Date d1,
java.util.Date d2)
Compute the working days between the two argument date
|
public static final int DATE
public static final int DATE_TIME
public static final int RFC1123
public static final int RFC1036
public static final int ANSI_C_ASCTIME
public static final int LOG_DATE
public static final int ISO
public static final int XML_DATE
public static final int XML_DATE_UTC
public static final int DATE_TIME_SEC
public static final int DATE_TIME_SEC_DIGITS
public static final int DATE_TIME_WITHOUT_ZONE
DATE_TIME
without zone infopublic static final long YEAR_THOUSAND
public static final long MILLISPERDAY
public static final int SECONDS
public static final int MINUTES
public static final int HOURS
public static final int DAYS
public static final int WEEK
public static final java.lang.String[] SHORT_UNIT_NAMES
public static final java.lang.String[] UNIT_NAMES
public static final long[] UNIT_FACTORS
public static java.util.Date addWorkdays(java.util.Date d1, int days)
d1
- days
- public static boolean areHolidaysConfigured()
true
if the special class was configured for
holidays; otherwise returns false
public static void deleteTimeInfoUntil(com.ibm.icu.util.Calendar cal, int field)
cal
- field
- public static int easterDay(int year)
year
- public static com.ibm.icu.util.Calendar getCalendar()
ThreadContext.getThreadLocale()
and ThreadContext.getThreadTimeZone()
getCalendar(Locale, TimeZone)
public static com.ibm.icu.util.Calendar getCalendar(java.util.Locale loc)
getCalendar(Locale, TimeZone)
public static com.ibm.icu.util.Calendar getCalendar(java.util.TimeZone tz)
getCalendar(Locale, TimeZone)
public static com.ibm.icu.util.Calendar getCalendar(java.util.Locale loc, java.util.TimeZone tz)
loc
- the locale if locale is null
, Locale.getDefault()
is usedtz
- the TimeZone if timezone is null
, TimeZone.getDefault()
is usedpublic static java.util.Calendar getJavaCalendar(com.ibm.icu.util.Calendar icuCalendar)
public static com.ibm.icu.text.DateFormatSymbols getDateFormatSymbols()
DateFormatSymbols
instance for the current ThreadContext.getThreadLocale()
getDateFormatSymbols(Calendar, Locale)
public static com.ibm.icu.text.DateFormatSymbols getDateFormatSymbols(com.ibm.icu.util.Calendar calendar, java.util.Locale loc)
DateFormatSymbols
instance for the specified Locale
and Calendar
Calendar
is null
getCalendar()
is usedLocale
is null
Locale.getDefault()
is usedcalendar
- the calendarloc
- the localepublic static com.ibm.icu.text.DateFormatSymbols getDateFormatSymbols(java.util.Locale loc)
loc
- the localegetDateFormatSymbols(Calendar, Locale)
public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(int type)
type
- is one of the integer constants of this class (DATE, RFC1123, ...)public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(int type, java.util.Locale loc)
type
- loc
- public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(int type, java.util.Locale locale, java.util.TimeZone timezone)
SimpleDateFormat
with the pattern specified by type
if the given type
has a fixed locale
/ timezone
the given locale
/ timezone
is ignoredtype
- one of DATE
,DATE_TIME
,DATE_TIME_SEC
,DATE_TIME_WITHOUT_ZONE
,DATE_TIME_SEC_DIGITS
locale
- the localetimezone
- the timezoneDateFormat
public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(int type, java.util.Locale locale, java.util.TimeZone timezone, com.ibm.icu.util.Calendar cal)
type
- one of DATE
,DATE_TIME
,DATE_TIME_SEC
,DATE_TIME_WITHOUT_ZONE
,DATE_TIME_SEC_DIGITS
locale
- the localetimezone
- the timezonecal
- the calendar to be usedDateFormat
public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(int type, java.util.TimeZone tz)
type
- tz
- getDateFormatter(int, Locale, TimeZone)
public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(java.lang.String pattern)
pattern
- getDateFormatter(String, Locale, TimeZone)
public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(java.lang.String pattern, java.util.Locale loc)
pattern
- loc
- getDateFormatter(String, Locale, TimeZone)
public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timezone)
SimpleDateFormat
instance for the pattern/locale/timezonepattern
- locale
- timezone
- public static com.ibm.icu.text.SimpleDateFormat getDateFormatter(java.lang.String pattern, java.util.TimeZone tz)
pattern
- tz
- getDateFormatter(String, Locale, TimeZone)
public static java.lang.String getIntervalInUnits(long interval)
interval
- duration in millisecondspublic static java.lang.String getIntervalInUnits(long interval, int maxunit)
public static java.lang.String getIntervalInUnits(long interval, int maxunit, int minunit)
public static java.lang.String getIntervalInUnits(long interval, int maxunit, int minunit, java.lang.String[] unitNames)
public static java.lang.String getIntervalInUnits(long interval, int maxunit, java.lang.String[] unitNames)
interval
- the intervall in millisecondesmaxunit
- unitNames
- - The UntiNames to use for the string representationpublic static java.lang.String getIntervalInUnits(long interval, java.lang.String maxunit)
interval
- the intervall in millisecondesmaxunit
- - the unis as string (maybe short or normal name)public static java.lang.String getIntervalInUnits(long interval, java.lang.String maxunit, java.lang.String minunit)
public static int getUnitIntFromString(java.lang.String unit)
public static java.lang.String isHoliday(com.ibm.icu.util.Calendar c)
public static boolean isNonWorkingDay(int day_of_week)
public static boolean isWorkingDay(com.ibm.icu.util.Calendar c)
c
- the given datepublic static java.util.Date parseDate(int type, java.lang.String dateString)
type
- dateString
- Date
instancepublic static java.util.Date parseDate(java.lang.String s)
s
- a string representing a date or date + timepublic static java.util.Date parseDateEndDay(java.lang.String s)
public static com.ibm.icu.util.TimeZone parseTimeZone(java.util.TimeZone tz)
public static void reconfigure()
public static void setDateFormatter(int type, com.ibm.icu.text.SimpleDateFormat df)
public static java.lang.String showDate(int type, java.util.Locale locale, java.util.TimeZone timezone, java.lang.Object d)
public static java.lang.String showDate(int type, java.lang.Object d)
public static java.lang.String showDate(java.lang.Object d)
d
- the date objectpublic static java.lang.String showDate(java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timeZone, java.lang.Object d)
public static java.lang.String showDate(java.lang.String pattern, java.lang.Object d)
public static java.lang.String showDateTime(java.lang.Object d)
d
- the date objectpublic static java.lang.String showDateTimeSeconds(java.lang.Object d)
d
- the date objectpublic static int thisYear()
public static java.util.Date toBeginDay(java.util.Date date)
date
- public static java.util.Date toEndDay(java.util.Date date)
date
- public static int workDaysBetween(java.util.Date d1, java.util.Date d2)
d1
- the start dated2
- the end datepublic static boolean isBetween(java.util.Date date, java.util.Date start, java.util.Date end)
@enterprise 9.0.33982 Copyright © 2001-2023 Groiss Informatics GmbH. All Rights Reserved.