public class CalUtil extends 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 Pattern |
NUMBER_CHECK_PATTERN |
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 String[] |
SHORT_UNIT_NAMES
short and normal names for TimeUnits
|
static long[] |
UNIT_FACTORS
the Unit Factorys
|
static 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 Date |
addWorkdays(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(Locale loc) |
static com.ibm.icu.util.Calendar |
getCalendar(Locale loc,
TimeZone tz)
Returns a calendar instance.
|
static com.ibm.icu.util.Calendar |
getCalendar(TimeZone tz) |
static DateFormatSymbols |
getDateFormatSymbols()
Returns a
DateFormatSymbols instance for the current ThreadContext.getThreadLocale() |
static DateFormatSymbols |
getDateFormatSymbols(com.ibm.icu.util.Calendar calendar,
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 DateFormatSymbols |
getDateFormatSymbols(Locale loc) |
static SimpleDateFormat |
getDateFormatter(int type)
Returns a thread save DateFormat object for the given format.
|
static SimpleDateFormat |
getDateFormatter(int type,
Locale loc)
Get local specific instance of predefined formatter types
|
static SimpleDateFormat |
getDateFormatter(int type,
Locale locale,
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 SimpleDateFormat |
getDateFormatter(int type,
Locale locale,
TimeZone timezone,
com.ibm.icu.util.Calendar cal) |
static SimpleDateFormat |
getDateFormatter(int type,
TimeZone tz) |
static SimpleDateFormat |
getDateFormatter(String pattern) |
static SimpleDateFormat |
getDateFormatter(String pattern,
Locale loc) |
static SimpleDateFormat |
getDateFormatter(String pattern,
Locale locale,
TimeZone timezone)
get a
SimpleDateFormat instance for the pattern/locale/timezone |
static SimpleDateFormat |
getDateFormatter(String pattern,
TimeZone tz) |
static String |
getIntervalInUnits(long interval)
Format a time interval.
|
static String |
getIntervalInUnits(long interval,
int maxunit) |
static String |
getIntervalInUnits(long interval,
int maxunit,
int minunit) |
static String |
getIntervalInUnits(long interval,
int maxunit,
int minunit,
String[] unitNames) |
static String |
getIntervalInUnits(long interval,
int maxunit,
String[] unitNames)
Returns a String representation of a TimeIntervall
|
static String |
getIntervalInUnits(long interval,
String maxunit)
Returns a String representation of a TimeIntervall using the short names of timeunits
|
static String |
getIntervalInUnits(long interval,
String maxunit,
String minunit) |
static Calendar |
getJavaCalendar(com.ibm.icu.util.Calendar icuCalendar) |
static int |
getUnitIntFromString(String unit) |
static boolean |
isBetween(Date date,
Date start,
Date end)
returns true if the passed date is not before start and not after end.
|
static 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 Date |
parseDate(int type,
String dateString)
parse a date from a string with the specified formatter
|
static Date |
parseDate(String s)
Parse a date from a string.
|
static Date |
parseDateEndDay(String s)
Parses the date sets the time to 23:59:59:999.
|
static Duration |
parseDuration(String duration,
String key)
Parses a time string to a java.time.Duration Object
|
static com.ibm.icu.util.TimeZone |
parseTimeZone(TimeZone tz) |
static void |
reconfigure() |
static void |
setDateFormatter(int type,
SimpleDateFormat df) |
static String |
showDate(int type,
Locale locale,
TimeZone timezone,
Object d) |
static String |
showDate(int type,
Object d) |
static String |
showDate(Object d)
Show the date using the default formatter.
|
static String |
showDate(String pattern,
Locale locale,
TimeZone timeZone,
Object d) |
static String |
showDate(String pattern,
Object d) |
static String |
showDateTime(Object d)
Show the date and time using the default formatter.
|
static String |
showDateTimeSeconds(Object d)
Show the date and time in the form yyyy-MM-dd HH:mm:ss.
|
static String |
showDuration(Object obj)
Show the duration in format *d*h*m*s
|
static int |
thisYear()
Return the current year.
|
static Date |
toBeginDay(Date date)
returns the date set to 00:00:00:00
|
static Date |
toEndDay(Date date)
returns a date set to 23:59:59:999
|
static int |
workDaysBetween(Date d1,
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 Pattern NUMBER_CHECK_PATTERN
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 String[] SHORT_UNIT_NAMES
public static final String[] UNIT_NAMES
public static final long[] UNIT_FACTORS
public static Date addWorkdays(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(Locale loc)
getCalendar(Locale, TimeZone)
public static com.ibm.icu.util.Calendar getCalendar(TimeZone tz)
getCalendar(Locale, TimeZone)
public static com.ibm.icu.util.Calendar getCalendar(Locale loc, TimeZone tz)
loc
- the locale if locale is null
, Locale.getDefault()
is usedtz
- the TimeZone if timezone is null
, TimeZone.getDefault()
is usedpublic static Calendar getJavaCalendar(com.ibm.icu.util.Calendar icuCalendar)
public static DateFormatSymbols getDateFormatSymbols()
DateFormatSymbols
instance for the current ThreadContext.getThreadLocale()
getDateFormatSymbols(Calendar, Locale)
public static DateFormatSymbols getDateFormatSymbols(com.ibm.icu.util.Calendar calendar, 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 DateFormatSymbols getDateFormatSymbols(Locale loc)
loc
- the localegetDateFormatSymbols(Calendar, Locale)
public static SimpleDateFormat getDateFormatter(int type)
type
- is one of the integer constants of this class (DATE, RFC1123, ...)public static SimpleDateFormat getDateFormatter(int type, Locale loc)
type
- loc
- public static SimpleDateFormat getDateFormatter(int type, Locale locale, 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 SimpleDateFormat getDateFormatter(int type, Locale locale, 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 SimpleDateFormat getDateFormatter(int type, TimeZone tz)
type
- tz
- getDateFormatter(int, Locale, TimeZone)
public static SimpleDateFormat getDateFormatter(String pattern)
pattern
- getDateFormatter(String, Locale, TimeZone)
public static SimpleDateFormat getDateFormatter(String pattern, Locale loc)
pattern
- loc
- getDateFormatter(String, Locale, TimeZone)
public static SimpleDateFormat getDateFormatter(String pattern, Locale locale, TimeZone timezone)
SimpleDateFormat
instance for the pattern/locale/timezonepattern
- locale
- timezone
- public static SimpleDateFormat getDateFormatter(String pattern, TimeZone tz)
pattern
- tz
- getDateFormatter(String, Locale, TimeZone)
public static String getIntervalInUnits(long interval)
interval
- duration in millisecondspublic static String getIntervalInUnits(long interval, int maxunit)
public static String getIntervalInUnits(long interval, int maxunit, int minunit)
public static String getIntervalInUnits(long interval, int maxunit, int minunit, String[] unitNames)
public static String getIntervalInUnits(long interval, int maxunit, String[] unitNames)
interval
- the intervall in millisecondesmaxunit
- unitNames
- - The UntiNames to use for the string representationpublic static String getIntervalInUnits(long interval, String maxunit)
interval
- the intervall in millisecondesmaxunit
- - the unis as string (maybe short or normal name)public static String getIntervalInUnits(long interval, String maxunit, String minunit)
public static int getUnitIntFromString(String unit)
public static 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 Date parseDate(int type, String dateString)
type
- dateString
- Date
instancepublic static Date parseDate(String s)
s
- a string representing a date or date + timepublic static Date parseDateEndDay(String s)
public static com.ibm.icu.util.TimeZone parseTimeZone(TimeZone tz)
public static void reconfigure()
public static void setDateFormatter(int type, SimpleDateFormat df)
public static String showDate(Object d)
d
- the date objectpublic static String showDateTime(Object d)
d
- the date objectpublic static String showDateTimeSeconds(Object d)
d
- the date objectpublic static Duration parseDuration(String duration, String key)
duration
- Can be a time string in format [dD][hH][mM][s[.f]S] or just secondskey
- The key of the propertypublic static int thisYear()
public static Date toBeginDay(Date date)
date
- public static Date toEndDay(Date date)
date
- public static int workDaysBetween(Date d1, Date d2)
d1
- the start dated2
- the end date@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.