|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.laliluna.date.Date
public class Date
The central class of this API which allows to create dates, substract them, add time to a date and more convient functions. There are methods to calculate working days between two dates. A nice feature is the option to move a date by a fractions. 1/1 is the next day, 24/25 is a day and an hour. It is mutable and not thread safe.
| Field Summary | |
|---|---|
static Fraction |
DAY
|
static Fraction |
HOUR
|
static Fraction |
MILLISECOND
|
static Fraction |
MINUTE
|
static Fraction |
SECOND
|
| Constructor Summary | |
|---|---|
Date()
Returns the current Date and Time, same as Date.now(); |
|
Date(java.util.Calendar calendar)
|
|
Date(Date date)
|
|
Date(java.util.Date date)
|
|
Date(int year,
int month,
int day)
|
|
Date(int year,
int month,
int day,
int hour,
int minute)
|
|
Date(int year,
int month,
int day,
int hour,
int minute,
int second)
|
|
Date(int year,
Months month,
int day)
|
|
Date(int year,
Months month,
int day,
int hour,
int minute)
|
|
Date(int year,
Months month,
int day,
int hour,
int minute,
int second)
|
|
Date(TimeZone timeZone)
|
|
| Method Summary | |
|---|---|
Date |
add(Fraction f)
Adds time expressed as fraction add(new Fraction(1/1)) - adds a day
add(new Fraction(1/24)) - adds an hour
add(new Fraction(5/1440)) - adds 5 minutes
The maximum you can add are 4085 years |
Date |
addDays(int day)
|
Date |
addHours(int hours)
|
Date |
addMilliSeconds(int milliSeconds)
|
Date |
addMinutes(int minutes)
|
Date |
addMonths(int month)
|
Date |
addSeconds(int seconds)
|
Date |
addYears(int years)
|
boolean |
after(Date other)
|
boolean |
afterDate(Date other)
|
boolean |
afterTime(Date other)
|
boolean |
am()
Ante Meridiem or AM |
boolean |
before(Date other)
|
boolean |
beforeDate(Date other)
|
boolean |
beforeTime(Date other)
|
int |
compareDateTo(java.util.Calendar other)
Compares only the date part of a date to the other dates date part. |
int |
compareDateTo(Date other)
Compares only the date part of a date to the other dates date part. |
int |
compareDateTo(java.util.Date other)
Compares only the date part of a date to the other dates date part. |
int |
compareTimeTo(java.util.Calendar other)
Compares only the time part of a date to the other dates time part. |
int |
compareTimeTo(Date other)
Compares only the time part of a date to the other dates time part. |
int |
compareTimeTo(java.util.Date other)
Compares only the time part of a date to the other dates time part. |
int |
compareTo(java.util.Calendar other)
Compares date and time parts of a date to the other date |
int |
compareTo(Date other)
Compares date and time parts of a date to the other date |
int |
compareTo(java.util.Date other)
Compares date and time parts of a date to the other date |
int |
day()
The day part of the date |
java.lang.String |
dayName()
Prints an English name of the month. |
int |
dayOfWeek()
Day of week is presented by 1 for Monday, 7 for Sunday, You can use the enum de.laliluna.date.Days to get a meaningful value |
java.lang.String |
dayShort()
Prints a short English name of the day. |
boolean |
equalDate(Date other)
|
boolean |
equalDateTime(Date other)
|
boolean |
equals(java.lang.Object o)
|
boolean |
equalTime(Date other)
|
int |
hashCode()
|
int |
hour()
returns the hour from the time part. |
int |
hour12()
returns the hours from the time part in a 0 to 12 range |
int |
millisecond()
Milli seconds of the time, there is no guaranty that the time is measured precisely |
Fraction |
minus(Date date)
Returns the time span between two dates as fraction 1/1 = 1 day, 1/24 = 1 hour, 26/24 = 1 day and 2 hours |
int |
minute()
Minute part of the time |
int |
month()
the month, 1 is January and 12 is December |
java.lang.String |
monthName()
Prints an English name of the month. |
java.lang.String |
monthShort()
Prints a short English name of the month. |
static Date |
now()
Creates a date and time instance for now |
static Date |
now(TimeZone timeZone)
Creates a date and time instance for now and sets the given timeZone |
boolean |
pm()
Post Meridiem or PM |
Date |
resetDate()
Sets year, month, day to zero |
Date |
resetTime()
Sets hour, minute, second and millisecond to zero |
int |
second()
Second part of the time |
Date |
setDay(int day)
|
Date |
setHour(int hours)
|
Date |
setMilliSeconds(int milliSeconds)
|
Date |
setMinute(int minutes)
|
Date |
setMonth(int month)
|
Date |
setMonth(Months month)
|
Date |
setSeconds(int seconds)
|
Date |
setTimeZone(TimeZone timeZone)
|
Date |
setYear(int year)
|
Date |
substract(Fraction f)
Subtracts a time span from the date |
long |
timeInMillis()
Returns milli seconds since 1.1.1970 0:00:00 UTC |
java.util.Calendar |
toCalendar()
Converts the date to java.util.Calendar |
static Date |
today()
Creates a date instance for todays date and sets the time to 00:00:00 000 |
static Date |
today(TimeZone timeZone)
Creates a date instance for todays date and the given timeZone, sets the time to 00:00:00 000 |
java.util.Date |
toJavaDate()
Converts the date to java.util.Date |
java.lang.String |
toString()
|
Date |
translate(TimeZone timeZone)
Translates the current Date to the passed time zone. |
Fraction |
workingDaysBetween(Date other)
Calculates the number of working days between to dates. |
Fraction |
workingDaysBetween(Date other,
DayFilter... dayFilter)
Calculates the number of working days between to dates. |
int |
year()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Fraction DAY
public static final Fraction HOUR
public static final Fraction MINUTE
public static final Fraction SECOND
public static final Fraction MILLISECOND
| Constructor Detail |
|---|
public Date()
Date.now();
public Date(TimeZone timeZone)
public Date(int year,
int month,
int day)
public Date(int year,
Months month,
int day)
public Date(int year,
int month,
int day,
int hour,
int minute)
public Date(int year,
Months month,
int day,
int hour,
int minute)
public Date(int year,
int month,
int day,
int hour,
int minute,
int second)
public Date(int year,
Months month,
int day,
int hour,
int minute,
int second)
public Date(Date date)
public Date(java.util.Calendar calendar)
public Date(java.util.Date date)
| Method Detail |
|---|
public static Date today()
public static Date today(TimeZone timeZone)
public static Date now()
public static Date now(TimeZone timeZone)
public Date resetDate()
public Date resetTime()
public Date add(Fraction f)
add(new Fraction(1/1)) - adds a day
add(new Fraction(1/24)) - adds an hour
add(new Fraction(5/1440)) - adds 5 minutes
The maximum you can add are 4085 years
f - - fraction to be added
public Date addYears(int years)
public Date addMonths(int month)
public Date addDays(int day)
public Date addHours(int hours)
public Date addMinutes(int minutes)
public Date addSeconds(int seconds)
public Date addMilliSeconds(int milliSeconds)
public Date setYear(int year)
public Date setMonth(int month)
public Date setMonth(Months month)
public Date setDay(int day)
public Date setHour(int hours)
public Date setMinute(int minutes)
public Date setSeconds(int seconds)
public Date setMilliSeconds(int milliSeconds)
public Date setTimeZone(TimeZone timeZone)
public Date substract(Fraction f)
f - - the time span
public Fraction minus(Date date)
date - - the date to be substracted
public Fraction workingDaysBetween(Date other)
other - - the other date
public Fraction workingDaysBetween(Date other,
DayFilter... dayFilter)
other - - the other date
public Date translate(TimeZone timeZone)
timeZone - - the target time zone
public int year()
public int month()
public int day()
public int dayOfWeek()
public int hour()
public int hour12()
public boolean am()
public boolean pm()
public int minute()
public int second()
public int millisecond()
public int compareTo(Date other)
compareTo in interface java.lang.Comparable<Date>other - - date to compare with
public int compareTo(java.util.Date other)
other - - date to compare with
public int compareTo(java.util.Calendar other)
other - - date to compare with
public int compareDateTo(Date other)
other - - date to compare with
public int compareDateTo(java.util.Date other)
other - - date to compare with
public int compareDateTo(java.util.Calendar other)
other - - date to compare with
public int compareTimeTo(Date other)
other - - date to compare with
public int compareTimeTo(java.util.Date other)
other - - date to compare with
public int compareTimeTo(java.util.Calendar other)
other - - date to compare with
public boolean before(Date other)
public boolean beforeDate(Date other)
public boolean beforeTime(Date other)
public boolean after(Date other)
public boolean afterDate(Date other)
public boolean afterTime(Date other)
public boolean equalDateTime(Date other)
public boolean equalDate(Date other)
public boolean equalTime(Date other)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.util.Calendar toCalendar()
public java.util.Date toJavaDate()
public long timeInMillis()
public java.lang.String monthShort()
public java.lang.String monthName()
public java.lang.String dayShort()
public java.lang.String dayName()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||