|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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 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 long |
YEAR_THOUSAND
the time value of the date object of date January 1, 1000 |
Method Summary | |
---|---|
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(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(java.util.Locale loc)
|
static Calendar |
getCalendar(java.util.Locale loc,
java.util.TimeZone tz)
Returns a calendar instance. |
static Calendar |
getCalendar(java.util.TimeZone tz)
|
static DateFormatSymbols |
getDateFormatSymbols()
Returns a DateFormatSymbols instance for the current ThreadContext.getThreadLocale() |
static DateFormatSymbols |
getDateFormatSymbols(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 DateFormatSymbols |
getDateFormatSymbols(java.util.Locale loc)
|
static SimpleDateFormat |
getDateFormatter(int type)
Returns a thread save DateFormat object for the given format. |
static SimpleDateFormat |
getDateFormatter(int type,
java.util.Locale loc)
Get local specific instance of predefined formatter types |
static 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 SimpleDateFormat |
getDateFormatter(int type,
java.util.Locale locale,
java.util.TimeZone timezone,
Calendar cal)
|
static SimpleDateFormat |
getDateFormatter(int type,
java.util.TimeZone tz)
|
static SimpleDateFormat |
getDateFormatter(java.lang.String pattern)
|
static SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.Locale loc)
|
static SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.Locale locale,
java.util.TimeZone timezone)
get a SimpleDateFormat instance for the pattern/locale/timezone |
static SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.TimeZone tz)
|
static java.lang.String |
getIntervalInUnits(long 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(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(Calendar c)
Returns null or the name of the holiday for the given day |
static boolean |
isNonWorkingDay(int day_of_week)
|
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. |
static TimeZone |
parseTimeZone(java.util.TimeZone tz)
|
static void |
reconfigure()
|
static void |
setDateFormatter(int type,
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 |
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 java.lang.String[] SHORT_UNIT_NAMES
public static final java.lang.String[] UNIT_NAMES
public static final long[] UNIT_FACTORS
Method Detail |
---|
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(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(java.util.Locale loc)
getCalendar(Locale, TimeZone)
public static Calendar getCalendar(java.util.TimeZone tz)
getCalendar(Locale, TimeZone)
public static 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 used
public static java.util.Calendar getJavaCalendar(Calendar icuCalendar)
public static DateFormatSymbols getDateFormatSymbols()
DateFormatSymbols
instance for the current ThreadContext.getThreadLocale()
getDateFormatSymbols(Calendar, Locale)
public static DateFormatSymbols getDateFormatSymbols(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 used
calendar
- the calendarloc
- the locale
public static DateFormatSymbols getDateFormatSymbols(java.util.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, java.util.Locale loc)
type
- loc
-
public static 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 ignored
type
- one of DATE
,DATE_TIME
,DATE_TIME_SEC
,DATE_TIME_WITHOUT_ZONE
,DATE_TIME_SEC_DIGITS
locale
- the localetimezone
- the timezone
DateFormat
public static SimpleDateFormat getDateFormatter(int type, java.util.Locale locale, java.util.TimeZone timezone, 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 used
DateFormat
public static SimpleDateFormat getDateFormatter(int type, java.util.TimeZone tz)
type
- tz
-
getDateFormatter(int, Locale, TimeZone)
public static SimpleDateFormat getDateFormatter(java.lang.String pattern)
pattern
-
getDateFormatter(String, Locale, TimeZone)
public static SimpleDateFormat getDateFormatter(java.lang.String pattern, java.util.Locale loc)
pattern
- loc
-
getDateFormatter(String, Locale, TimeZone)
public static SimpleDateFormat getDateFormatter(java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timezone)
SimpleDateFormat
instance for the pattern/locale/timezone
pattern
- locale
- timezone
-
public static SimpleDateFormat getDateFormatter(java.lang.String pattern, java.util.TimeZone tz)
pattern
- tz
-
getDateFormatter(String, Locale, TimeZone)
public static java.lang.String getIntervalInUnits(long interval)
public 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 representation
public 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(Calendar c)
public static boolean isNonWorkingDay(int day_of_week)
public 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 + time
public static java.util.Date parseDateEndDay(java.lang.String s)
public static TimeZone parseTimeZone(java.util.TimeZone tz)
public static void reconfigure()
public static void setDateFormatter(int type, 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 date
public static boolean isBetween(java.util.Date date, java.util.Date start, java.util.Date end)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |