|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jaulp.date.DateUtils
public class DateUtils
Utility class for the use of Date and Calendar object.
Field Summary |
---|
Fields inherited from interface net.sourceforge.jaulp.date.DatePatterns |
---|
DD_MMM_YY, DOT_DD_MM, DOT_DD_MM_YY, DOT_DD_MM_YYYY, DOT_DD_MM_YYYY_HH_MM_SS, DOT_YYYY_MM_DD_HH_MM_SS, EEE_MMM_DD_HH_MM_SS_Z_YYYY, EEEE_MMM_DD_YYYY, LHH_MM_SS, UHH_MM_SS, YYYY_MM_DD, YYYY_MM_DD_HH_MM_SS, YYYY_MM_DD_HH_MM_SS_S, YYYY_MM_DD_T_HH_MM_SS, YYYYMMDDHHMMSS |
Method Summary | |
---|---|
static java.util.Date |
addDaysToDate(java.util.Date date,
int addDays)
Adds days to the given Date object and returns it. |
static java.util.Date |
addYearsToDate(java.util.Date date,
int addYears)
Adds years to the given Date object and returns it. |
static long |
calculateElapsedTime(java.util.Date past,
java.util.Date now)
Calculates the elapsed time from the past to now. |
static long |
calculateTimeFromNow(java.util.Date now,
java.util.Date future)
Calculates the elapsed time from the future to now. |
static int |
computeAge(java.util.Date birthday,
java.util.Date computeDate)
Computes the Age from the birthday till the computeDate object. |
static java.util.Date |
computeEasternSunday(int year)
Computes the eastern sunday for the given year. |
static int |
computeEasternSundayNumber(int year)
Computes the number from eastern sunday for the given year. |
java.util.Calendar |
convertDateToCalendar(java.util.Date date)
Converts the given Date object to a Calendar object. |
static java.util.Calendar |
convertToCalendar(java.util.Date date)
Converts a Date to a Calendar-object. |
static java.util.Date |
convertToDate(java.util.Calendar calendar)
Converts a Calendar-object to a Date. |
static java.sql.Timestamp |
convertToTimestamp(java.util.Date date)
Converts a Date to a Timestamp-object. |
static java.util.Date |
createDate(int year,
int month,
int day)
Creates a Date object from the given values. |
static java.util.Date |
createDate(int year,
int month,
int day,
int hour,
int min,
int sec)
Creates a Date object from the given values. |
static java.util.Date |
createRandomBirthday()
Creates a random Birthday between the range 9 and 55 years. |
static java.util.Date |
createRandomBirthday(java.util.Date from,
java.util.Date till)
Creates a random Birthday between the given two Date objects. |
static java.util.Date |
createRandomDate(java.util.Date from)
Deprecated. Use instead RandomDateUtils.createRandomDate( from ). |
static java.util.Date |
createRandomDatebetween(java.util.Date start,
java.util.Date end)
Deprecated. Use instead RandomDateUtils.createRandomDatebetween(start, end ). |
static java.util.Date |
createRandomDateBetween(java.util.Date from,
int startDays,
int endDays)
Deprecated. Use instead RandomDateUtils.createRandomDateBetween( from, startDays, endDays ). |
static java.lang.String |
createRandomDatebetween(long startDate,
long endDate)
Deprecated. Use instead RandomDateUtils.createRandomDatebetween( startDate, endDate, format ). |
static java.lang.String |
createRandomDatebetween(long startDate,
long endDate,
java.lang.String format)
Deprecated. Use instead RandomDateUtils.createRandomDatebetween( startDate, endDate, format ). |
static java.util.List |
getAllDateFormats()
Returns a list with all dateformats from the Interface DateFormats. |
static java.util.Map<java.lang.String,java.lang.Object> |
getAllDatePatterns()
Returns a map with all datepatterns from the Interface DatePatterns. |
static int |
getDay(java.util.Date date)
The Method from the Date.getDay is deprecated. |
static int |
getHours(java.util.Date date)
The Method from the Date.getHours is deprecated. |
static int |
getMinutes(java.util.Date date)
The Method from the Date.getMinutes is deprecated. |
static int |
getMonth(java.util.Date date)
The Method from the Date.getMonth is deprecated. |
static int |
getSeconds(java.util.Date date)
The Method from the Date.getSeconds is deprecated. |
static int |
getYear(java.util.Date date)
The Method from the Date.getYear is deprecated. |
static boolean |
isBetween(java.util.Date start,
java.util.Date end,
java.util.Date between)
Checks if the Date object "between" is between from the given to Date objects. |
static boolean |
isDateInTheFuture(java.util.Date date)
Checks if the given date object is in the future. |
static boolean |
isDateInThePast(java.util.Date date)
Checks if the given date object is in the past. |
static boolean |
isLeapYear(int year)
Determines if the given year is a leap year. |
static boolean |
isValidDate(java.lang.String date,
java.lang.String format,
boolean lenient)
Checks if the Date is valid to convert. |
static java.util.Date |
parseDate(java.lang.String date,
java.util.List<java.lang.String> patterns)
Tries to convert the given String to a Date. |
static java.util.Date |
parseToDate(java.lang.String date,
java.lang.String format)
Parses the String date to a date object. |
static java.util.Date |
parseToDate(java.lang.String datum,
java.lang.String[] formats,
java.util.Locale locale)
Returns a date-object if the array with the formats are valid otherwise null. |
static java.util.Date |
parseToDateLenient(java.lang.String date,
java.lang.String format,
boolean lenient)
Parses the String date to a date object. |
static java.lang.String |
parseToString(java.util.Date date,
java.lang.String format)
The Method parseToString(Date, String) formats the given Date to the given Format. |
static java.util.Date |
substractDaysFromDate(java.util.Date date,
int substractDays)
Substract days to the given Date object and returns it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.Date addDaysToDate(java.util.Date date, int addDays)
date
- The Date object to add the days.addDays
- The days to add.
public static java.util.Date addYearsToDate(java.util.Date date, int addYears)
date
- The Date object to add the years.addYears
- The years to add.
public static long calculateElapsedTime(java.util.Date past, java.util.Date now)
past
- The Date object in the past.now
- The Date from now.
public static long calculateTimeFromNow(java.util.Date now, java.util.Date future)
now
- The Date from now.future
- The Date in the future.
public static int computeAge(java.util.Date birthday, java.util.Date computeDate)
birthday
- The Date object from the birthday.computeDate
- The Date-object from where to compute.
public static java.util.Date computeEasternSunday(int year)
year
- The year to compute the eastern sunday.
public static int computeEasternSundayNumber(int year)
year
- The year to compute the number from eastern sunday.
public static java.util.Calendar convertToCalendar(java.util.Date date)
date
- The date to convert.
public static java.util.Date convertToDate(java.util.Calendar calendar)
calendar
- The calendar to convert.
public static java.sql.Timestamp convertToTimestamp(java.util.Date date)
date
- The date to convert.
public static java.util.Date createDate(int year, int month, int day)
year
- The year.month
- The month.day
- The day.
public static java.util.Date createDate(int year, int month, int day, int hour, int min, int sec)
year
- The year.month
- The month.day
- The day.hour
- The hour.min
- The minutes.sec
- The seconds.
public static java.util.Date createRandomBirthday()
public static java.util.Date createRandomBirthday(java.util.Date from, java.util.Date till)
from
- A Date object before the Date object "till".till
- A Date object after the Date object "from".
@Deprecated public static java.util.Date createRandomDate(java.util.Date from)
from
- The Date from where the range starts to the past.
@Deprecated public static java.util.Date createRandomDatebetween(java.util.Date start, java.util.Date end)
start
- The Date from where the range starts.end
- The Date from where the range ends.
@Deprecated public static java.lang.String createRandomDatebetween(long startDate, long endDate)
startDate
- The Date from where the random Date to start.endDate
- The Date from where the random Date to end.
@Deprecated public static java.lang.String createRandomDatebetween(long startDate, long endDate, java.lang.String format)
startDate
- The Date from where the random Date to start.endDate
- The Date from where the random Date to end.format
- The pattern from the Date.
@Deprecated public static java.util.Date createRandomDateBetween(java.util.Date from, int startDays, int endDays)
from
- The Date from where to the random Date to start.startDays
- The int that represents the days from where the range starts.endDays
- The int that represents the days from where the range ends.
public static java.util.List getAllDateFormats()
public static java.util.Map<java.lang.String,java.lang.Object> getAllDatePatterns()
public static int getDay(java.util.Date date)
date
- The Date-object to get the day.
public static int getHours(java.util.Date date)
date
- The Date-object to get the hours.
public static int getMinutes(java.util.Date date)
date
- The Date-object to get the minutes.
public static int getMonth(java.util.Date date)
date
- The Date-object to get the month.
public static int getSeconds(java.util.Date date)
date
- The Date-object to get the seconds.
public static int getYear(java.util.Date date)
date
- The Date-object to get the year.
public static boolean isBetween(java.util.Date start, java.util.Date end, java.util.Date between)
start
- the start time.end
- the end time.between
- the date to compare if it is between.
public static boolean isDateInTheFuture(java.util.Date date)
date
- The date to check.
public static boolean isDateInThePast(java.util.Date date)
date
- The date to check.
public static boolean isLeapYear(int year)
year
- The year to determine.
public static boolean isValidDate(java.lang.String date, java.lang.String format, boolean lenient)
date
- The Date as Stringformat
- The Format for the Date to parselenient
- Specify whether or not date/time interpretation is to be
lenient.
public static java.util.Date parseDate(java.lang.String date, java.util.List<java.lang.String> patterns)
date
- The date to convert as String.patterns
- The date patterns to convert the String to a date-object.
public static java.util.Date parseToDate(java.lang.String date, java.lang.String format)
date
- The Date as Stringformat
- The Format for the Date to parse
java.text.ParseException
- occurs when their are problems with parsing the String to
Date.public static java.util.Date parseToDate(java.lang.String datum, java.lang.String[] formats, java.util.Locale locale)
datum
- The date as string which to parse to a date-object.formats
- The string-array with the date-patterns.locale
- THe Locale for the SimpleDateFormat.
public static java.util.Date parseToDateLenient(java.lang.String date, java.lang.String format, boolean lenient)
date
- The Date as Stringformat
- The Format for the Date to parselenient
- Specify whether or not date/time interpretation is to be
lenient.
public static java.lang.String parseToString(java.util.Date date, java.lang.String format)
date
- The Date to format to a Stringformat
- The Format for the date
public static java.util.Date substractDaysFromDate(java.util.Date date, int substractDays)
date
- The Date object to substract the days.substractDays
- The days to substract.
public java.util.Calendar convertDateToCalendar(java.util.Date date)
date
- The Date object to convert.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |