| java.lang.Object org.zkoss.util.Dates
Dates | public class Dates (Code) | | Utilities for java.util.Date
author: henrichen author: tomyeh |
Method Summary | |
final public static Date | add(Date when, TimeZone tz, int field, int amount) Date Arithmetic function. | final public static Date | beginOfDate(Date when, TimeZone tz) Given a date, a proper TimeZone, return the beginning date of
the specified date and TimeZone. | final public static Date | beginOfMonth() Return the beginning date of this month. | final public static Date | beginOfMonth(Date when, TimeZone tz) Given a date, a proper TimeZone, return the beginning date of the
month of the specified date and TimeZone. | final public static Date | beginOfYear() Return the beginning date of this year. | final public static Date | beginOfYear(Date when, TimeZone tz) Given a date, a proper TimeZone, return the beginning date of the
month of the specified date and TimeZone. | final public static int | dayMonthOfDate(Date when, TimeZone tz) Get the day of month of a date. | final public static Date | endOfDate(Date when, TimeZone tz) Given a date, a proper TimeZone, return the last millisecond date of
the specified date and TimeZone. | final public static Date | endOfMonth() Return the ending date of this month. | final public static Date | endOfMonth(Date when, TimeZone tz) Given a date, a proper TimeZone, return the ending date of the
month of the specified date and TimeZone. | final public static Date | endOfYear() Return the ending date of this year. | final public static Date | endOfYear(Date when, TimeZone tz) Given a date, a proper TimeZone, return the ending date of the
month of the specified date and TimeZone. | final public static boolean | isBeginOfMonth(Date when, TimeZone tz) Whether the given date in the specified TimeZone is the first day of that
month. | final public static boolean | isEndOfMonth(Date when, TimeZone tz) Whether the given date in the specified TimeZone is the last day of that
month. | final public static boolean | isRounded(Date date, int precision) Tests whether a date is rounded. | final public static int | localizedYearOfDate(Date when, Locale locale, TimeZone tz) Get the year of a date in the specified locale.
Currenty, only Locale.ZH_TW is supported, i.e.,
"year - 1911" and it's may be less than 0. | final public static Date | merge(Date datePart, Date timePart, TimeZone tz) merge the date part and time part of two specified dates into a date. | final public static int | monthOfDate(Date when, TimeZone tz) Get the month of a date. | final public static int | monthOfDatePlus1(Date when, TimeZone tz) Get the month of a date. | final public static Date | now(int precision) Returns the current time but rounding to the specified precision
of milliseconds. | final public static Date | now() Returns the current time without rounding. | final public static Date | previousDate(Date when) Given a date, return the previouse date of the given date (24 hrs before). | final public static Date | round(Date date, int precision) Truncates date to the nearest precision milliseconds. | final public static long | round(long time, int precision) Rounds a date represented in long to the specified precision of
milliseconds.
Parameters: time - the date represented in long. Parameters: precision - the divider of the precision(e.g. | final public static long | subtract(Date date2, TimeZone tz, int field, Date date1) Date Arithmetic function (date2 - date1). | final public static Date | today() Returns today by setting time to 0:0:0. | final public static short | twoMonthShort() Return the ending date of this year. | final public static short | twoMonthShort(Date when, TimeZone tz) Given a date, a proper TimeZone, return the two month int. | final public static int | yearOfDate(Date when, TimeZone tz) Get the year of a date. |
add | final public static Date add(Date when, TimeZone tz, int field, int amount)(Code) | | Date Arithmetic function. Adds the specified (signed) amount of time to the given date,
based on the calendar's rules.
Parameters: when - The based date. Parameters: tz - The time zone; if null, the current time zone is assumed. Parameters: field - The time field. Parameters: amount - The amount of date or time to be added to the field. |
beginOfDate | final public static Date beginOfDate(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the beginning date of
the specified date and TimeZone. If TimeZone is null, meaning use Defult
TimeZone of the JVM.
|
beginOfMonth | final public static Date beginOfMonth()(Code) | | Return the beginning date of this month.
|
beginOfMonth | final public static Date beginOfMonth(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the beginning date of the
month of the specified date and TimeZone.
If TimeZone is null, meaning use default TimeZone of the JVM.
|
beginOfYear | final public static Date beginOfYear()(Code) | | Return the beginning date of this year.
|
beginOfYear | final public static Date beginOfYear(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the beginning date of the
month of the specified date and TimeZone.
If TimeZone is null, meaning use default TimeZone of the JVM.
|
dayMonthOfDate | final public static int dayMonthOfDate(Date when, TimeZone tz)(Code) | | Get the day of month of a date. The first day of the month has value 1.
Parameters: when - The date. Parameters: tz - The time zone; if null, the current time zone is assumed. |
endOfDate | final public static Date endOfDate(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the last millisecond date of
the specified date and TimeZone. If TimeZone is null, meaning use Defult
TimeZone of the JVM.
|
endOfMonth | final public static Date endOfMonth()(Code) | | Return the ending date of this month.
|
endOfMonth | final public static Date endOfMonth(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the ending date of the
month of the specified date and TimeZone.
If TimeZone is null, meaning use default TimeZone of the JVM.
|
endOfYear | final public static Date endOfYear()(Code) | | Return the ending date of this year.
|
endOfYear | final public static Date endOfYear(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the ending date of the
month of the specified date and TimeZone.
If TimeZone is null, meaning use default TimeZone of the JVM.
|
isBeginOfMonth | final public static boolean isBeginOfMonth(Date when, TimeZone tz)(Code) | | Whether the given date in the specified TimeZone is the first day of that
month. If TimeZone is null, meaning use default TimeZone of the JVM.
|
isEndOfMonth | final public static boolean isEndOfMonth(Date when, TimeZone tz)(Code) | | Whether the given date in the specified TimeZone is the last day of that
month. If TimeZone is null, meaning use default TimeZone of the JVM.
|
isRounded | final public static boolean isRounded(Date date, int precision)(Code) | | Tests whether a date is rounded.
It is mainly used for debugging.
|
localizedYearOfDate | final public static int localizedYearOfDate(Date when, Locale locale, TimeZone tz)(Code) | | Get the year of a date in the specified locale.
Currenty, only Locale.ZH_TW is supported, i.e.,
"year - 1911" and it's may be less than 0. Otherwise, it is the same
as
Dates.yearOfDate .
Parameters: when - The date. Parameters: locale - the locale; if null, the current locale is assumed. Parameters: tz - The time zone; if null, the current time zone is assumed. See Also: Dates.yearOfDate |
merge | final public static Date merge(Date datePart, Date timePart, TimeZone tz)(Code) | | merge the date part and time part of two specified dates into a date.
Parameters: datePart - The date part date. Parameters: timePart - The time part date. Parameters: tz - The time zone. |
monthOfDate | final public static int monthOfDate(Date when, TimeZone tz)(Code) | | Get the month of a date. The first month of the year is JANUARY which is 0.
Parameters: when - The date. Parameters: tz - The time zone; if null, the current time zone is assumed. |
monthOfDatePlus1 | final public static int monthOfDatePlus1(Date when, TimeZone tz)(Code) | | Get the month of a date. The first month of the year is JANUARY which is 1.
Parameters: when - The date. Parameters: tz - The time zone; if null, the current time zone is assumed. |
now | final public static Date now(int precision)(Code) | | Returns the current time but rounding to the specified precision
of milliseconds. It is useful if you want to create the current time
which will be stored in the database and want to compare it with
something with what you store in the database. Otherwise, that you
get back the one you store might be different, because the resolution
of database timestamp is usually less than one milisecond,
e.g., MS SQL: 0.003 second.
If you don't cache it in the memory (remember entity beans
always cache by the container), you don't need to round. If you
are not sure, round it.
See Also: Dates.round(Date,int) |
now | final public static Date now()(Code) | | Returns the current time without rounding.
|
previousDate | final public static Date previousDate(Date when)(Code) | | Given a date, return the previouse date of the given date (24 hrs before).
|
round | final public static Date round(Date date, int precision)(Code) | | Truncates date to the nearest precision milliseconds. MS SQLServer2000
with only the maximum accuracy of 1/300 seconds would not be able to
store up to one millisecond accurarcy. That is, User must round the
millisecond to some less precisions; or the data in that db would be
inconsistence with that in memory.
It is useful to store a Date object in a database.
Without rounding, if you want to get it back and compare with the
one in the memory. See
Dates.now for details.
Parameters: precision - the divider of the precision(e.g. 10 for precisionof 10 milliseconds;i.e. all millisecond less than 10 would be truncated) See Also: Dates.now See Also: Dates.round(long,int) |
round | final public static long round(long time, int precision)(Code) | | Rounds a date represented in long to the specified precision of
milliseconds.
Parameters: time - the date represented in long. Parameters: precision - the divider of the precision(e.g. 10 for precisionof 10 milliseconds;i.e. all millisecond less than 10 would be truncated) See Also: Dates.now See Also: Dates.round(Date,int) |
subtract | final public static long subtract(Date date2, TimeZone tz, int field, Date date1)(Code) | | Date Arithmetic function (date2 - date1). subtract a date from another date, return the
difference as the required fields. E.g. if specified Calendar.Date, the
smaller range of fields is ignored and this method return the difference
of days.
Parameters: date2 - The date2. Parameters: tz - The time zone. Parameters: field - The time field; e.g., Calendar.DATE, Calendar.YEAR, it's default value is Calendar.DATE Parameters: date1 - The date1. |
today | final public static Date today()(Code) | | Returns today by setting time to 0:0:0.
|
twoMonthShort | final public static short twoMonthShort()(Code) | | Return the ending date of this year.
|
twoMonthShort | final public static short twoMonthShort(Date when, TimeZone tz)(Code) | | Given a date, a proper TimeZone, return the two month int. eg. 1, 3, 5, 7, 9, 11.
If TimeZone is null, meaning use default TimeZone of the JVM.
|
yearOfDate | final public static int yearOfDate(Date when, TimeZone tz)(Code) | | Get the year of a date.
Parameters: when - The date. Parameters: tz - The time zone; if null, the current time zone is assumed. See Also: Dates.localizedYearOfDate |
|
|