|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.groiss.cal.CalUtil
public class CalUtil
This class provides some utilities for date and time handling. It uses two properties: 'DateFormat' and 'DateTimeFormat' which must be set in the default configuration object. The integer constants in this class can be used with the method getDateFormatter to get a thread save DateFormat instance for this format.
| Field Summary | |
|---|---|
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 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 long |
YEAR_THOUSAND
the time value of the date object of date January 1, 1000 |
| Method Summary | |
|---|---|
static Date |
addWorkdays(Date d1,
int days)
adds the specified amount of workdays to the given date |
static boolean |
areHolidaysConfigured()
|
static void |
deleteTimeInfoUntil(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 Calendar |
getCalendar()
|
static Calendar |
getCalendar(Locale loc)
|
static Calendar |
getCalendar(Locale loc,
TimeZone tz)
Returns a calendar instance. |
static Calendar |
getCalendar(TimeZone tz)
|
static DateFormatSymbols |
getDateFormatSymbols()
Returns a DateFormatSymbols instance for the current ThreadContext.getThreadLocale() |
static DateFormatSymbols |
getDateFormatSymbols(Calendar calendar,
Locale loc)
Returns a DateFormatSymbols instance for the specified Locale
and Calendarif 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,
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)
|
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(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(Calendar c)
Returns null or the name of the holiday for the given day |
static boolean |
isNonWorkingDay(int day_of_week)
|
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. |
static 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 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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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 DATE_TIME_SEC
public static final int DATE_TIME_SEC_DIGITS
public static final int DATE_TIME_WITHOUT_ZONE
DATE_TIME without zone info
public 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 String[] SHORT_UNIT_NAMES
public static final String[] UNIT_NAMES
public static final long[] UNIT_FACTORS
| Method Detail |
|---|
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(Calendar cal,
int field)
cal - field - public static int easterDay(int year)
year -
public static Calendar getCalendar()
ThreadContext.getThreadLocale() and ThreadContext.getThreadTimeZone()getCalendar(Locale, TimeZone)public static Calendar getCalendar(Locale loc)
getCalendar(Locale, TimeZone)public static Calendar getCalendar(TimeZone tz)
getCalendar(Locale, TimeZone)
public static 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 used
public static Calendar getJavaCalendar(Calendar icuCalendar)
public static DateFormatSymbols getDateFormatSymbols()
DateFormatSymbols instance for the current ThreadContext.getThreadLocale()
getDateFormatSymbols(Calendar, Locale)
public static DateFormatSymbols getDateFormatSymbols(Calendar calendar,
Locale loc)
DateFormatSymbols instance for the specified Locale
and CalendarCalendar is null getCalendar() is usedLocale is null Locale.getDefault() is used
calendar - the calendarloc - the locale
public static DateFormatSymbols getDateFormatSymbols(Locale loc)
loc - the locale
getDateFormatSymbols(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 ignored
type - one of DATE,DATE_TIME,DATE_TIME_SEC,DATE_TIME_WITHOUT_ZONE,DATE_TIME_SEC_DIGITSlocale - the localetimezone - the timezone
DateFormat
public static SimpleDateFormat getDateFormatter(int type,
Locale locale,
TimeZone timezone,
Calendar cal)
type - one of DATE,DATE_TIME,DATE_TIME_SEC,DATE_TIME_WITHOUT_ZONE,DATE_TIME_SEC_DIGITSlocale - the localetimezone - the timezonecal - the calendar to be used
DateFormat
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/timezone
pattern - locale - timezone -
public static SimpleDateFormat getDateFormatter(String pattern,
TimeZone tz)
pattern - tz -
getDateFormatter(String, Locale, TimeZone)public static String getIntervalInUnits(long interval)
public 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 representation
public 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(Calendar c)
public static boolean isNonWorkingDay(int day_of_week)
public static Date parseDate(int type,
String dateString)
type - dateString -
Date instancepublic static Date parseDate(String s)
s - a string representing a date or date + time
public static Date parseDateEndDay(String s)
public static TimeZone parseTimeZone(TimeZone tz)
public static void reconfigure()
public static void setDateFormatter(int type,
SimpleDateFormat df)
public static String showDate(int type,
Locale locale,
TimeZone timezone,
Object d)
public static String showDate(int type,
Object d)
public static String showDate(Object d)
d - the date object
public static String showDate(String pattern,
Locale locale,
TimeZone timeZone,
Object d)
public static String showDate(String pattern,
Object d)
public static String showDateTime(Object d)
d - the date objectpublic static String showDateTimeSeconds(Object d)
d - the date objectpublic 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
public static boolean isBetween(Date date,
Date start,
Date end)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||