|
|||||||||
| 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 |
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 boolean[] |
nonWorkingDays
|
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
|
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 |
| Constructor Summary | |
|---|---|
CalUtil()
|
|
| Method Summary | |
|---|---|
static java.util.Date |
addWorkdays(java.util.Date d1,
int days)
|
static int |
easterDay(int year)
|
static java.util.Calendar |
getCalendar(java.util.Locale loc)
Returns a calendar instance. |
static java.text.DateFormat |
getDateFormatter(int type)
Returns a thread save DateFormat object for the given format. |
static java.text.SimpleDateFormat |
getDateFormatter(int type,
java.util.Locale loc)
Get local specific instance of predefined formatter types |
static java.text.SimpleDateFormat |
getDateFormatter(java.lang.String pattern,
java.util.Locale loc)
Returns the date formatter defined in the configuration parameter "date.format.class". |
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 int |
getUnitIntFromString(java.lang.String unit)
|
static java.lang.String |
isHoliday(java.util.Calendar c)
Returns null or the name of the holiday for the given day |
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 void |
setDateFormatter(int type,
java.text.DateFormat df)
|
static java.lang.String |
showDate(java.util.Date d)
Show the date using the default formatter. |
static java.lang.String |
showDateTime(java.util.Date d)
Show the date and time using the default formatter. |
static int |
thisYear()
Return the current year. |
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 int DATE
public static int DATE_TIME
public static int RFC1123
public static int RFC1036
public static int ANSI_C_ASCTIME
public static int LOG_DATE
public static int ISO
public static int XML_DATE
public static int DATE_TIME_SEC
public static int DATE_TIME_SEC_DIGITS
public static final long YEAR_THOUSAND
public static final long MILLISPERDAY
public static boolean[] nonWorkingDays
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
| Constructor Detail |
|---|
public CalUtil()
| Method Detail |
|---|
public static int thisYear()
public static java.util.Date parseDate(java.lang.String s)
throws java.lang.Exception
s - a string representing a date or date + time
java.lang.Exception
public static java.util.Date parseDateEndDay(java.lang.String s)
throws java.lang.Exception
java.lang.Exceptionpublic static java.text.DateFormat getDateFormatter(int type)
type - is one of the integer constants of this class (DATE, RFC1123, ...)
public static java.text.SimpleDateFormat getDateFormatter(java.lang.String pattern,
java.util.Locale loc)
throws java.lang.SecurityException,
java.lang.NoSuchMethodException,
java.lang.IllegalArgumentException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
pattern - loc -
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static java.text.SimpleDateFormat getDateFormatter(int type,
java.util.Locale loc)
throws java.lang.SecurityException,
java.lang.NoSuchMethodException,
java.lang.IllegalArgumentException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
type - loc -
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static java.util.Calendar getCalendar(java.util.Locale loc)
throws java.lang.SecurityException,
java.lang.NoSuchMethodException,
java.lang.IllegalArgumentException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
loc - the locale is used to get the calendar for the right locale (for example to determine
first day of week.
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static void setDateFormatter(int type,
java.text.DateFormat df)
public static java.lang.String showDateTime(java.util.Date d)
d - the date objectpublic static java.lang.String showDate(java.util.Date d)
d - the date objectpublic static java.lang.String isHoliday(java.util.Calendar c)
public static int workDaysBetween(java.util.Date d1,
java.util.Date d2)
d1 - the start dated2 - the end date
public static java.util.Date addWorkdays(java.util.Date d1,
int days)
public static int easterDay(int year)
public static int getUnitIntFromString(java.lang.String unit)
public static java.lang.String getIntervalInUnits(long interval)
public static java.lang.String getIntervalInUnits(long interval,
java.lang.String maxunit)
interval - the intervall in millisecondesunit - - 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 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,
java.lang.String[] unitNames)
interval - the intervall in millisecondesunit - - the unis as string (maybe short or normal name)unitNames - - The UntiNames to use for the string representation
public static java.lang.String getIntervalInUnits(long interval,
int maxunit,
int minunit,
java.lang.String[] unitNames)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||