|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.util.Dates
public class Dates
Utilities for java.util.Date
Constructor Summary | |
---|---|
Dates()
|
Method Summary | |
---|---|
static java.util.Date |
add(java.util.Date when,
java.util.TimeZone tz,
int field,
int amount)
Date Arithmetic function. |
static java.util.Date |
beginOfDate(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the beginning date of the specified date and TimeZone. |
static java.util.Date |
beginOfMonth()
Return the beginning date of this month. |
static java.util.Date |
beginOfMonth(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the beginning date of the month of the specified date and TimeZone. |
static java.util.Date |
beginOfYear()
Return the beginning date of this year. |
static java.util.Date |
beginOfYear(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the beginning date of the month of the specified date and TimeZone. |
static int |
dayMonthOfDate(java.util.Date when,
java.util.TimeZone tz)
Get the day of month of a date. |
static java.util.Date |
endOfDate(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the last millisecond date of the specified date and TimeZone. |
static java.util.Date |
endOfMonth()
Return the ending date of this month. |
static java.util.Date |
endOfMonth(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the ending date of the month of the specified date and TimeZone. |
static java.util.Date |
endOfYear()
Return the ending date of this year. |
static java.util.Date |
endOfYear(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the ending date of the month of the specified date and TimeZone. |
static long |
getTimezoneOffset(java.util.TimeZone timezone,
java.util.Date date)
Returns the timezone offset. |
static boolean |
isBeginOfMonth(java.util.Date when,
java.util.TimeZone tz)
Whether the given date in the specified TimeZone is the first day of that month. |
static boolean |
isEndOfMonth(java.util.Date when,
java.util.TimeZone tz)
Whether the given date in the specified TimeZone is the last day of that month. |
static boolean |
isRounded(java.util.Date date,
int precision)
Tests whether a date is rounded. |
static int |
localizedYearOfDate(java.util.Date when,
java.util.Locale locale,
java.util.TimeZone tz)
Get the year of a date in the specified locale. |
static java.util.Date |
merge(java.util.Date datePart,
java.util.Date timePart,
java.util.TimeZone tz)
merge the date part and time part of two specified dates into a date. |
static int |
monthOfDate(java.util.Date when,
java.util.TimeZone tz)
Get the month of a date. |
static int |
monthOfDatePlus1(java.util.Date when,
java.util.TimeZone tz)
Get the month of a date. |
static java.util.Date |
now()
Returns the current time without rounding. |
static java.util.Date |
now(int precision)
Returns the current time but rounding to the specified precision of milliseconds. |
static java.util.Date |
previousDate(java.util.Date when)
Given a date, return the previous date of the given date (24 hrs before). |
static java.util.Date |
round(java.util.Date date,
int precision)
Truncates date to the nearest precision milliseconds. |
static long |
round(long time,
int precision)
Rounds a date represented in long to the specified precision of milliseconds. |
static long |
subtract(java.util.Date date2,
java.util.TimeZone tz,
int field,
java.util.Date date1)
Date Arithmetic function (date2 - date1). subtract a date from another date, return the difference as the required fields. |
static java.util.Date |
today()
Returns today by setting time to 0:0:0. |
static short |
twoMonthShort()
Return the ending date of this year. |
static short |
twoMonthShort(java.util.Date when,
java.util.TimeZone tz)
Given a date, a proper TimeZone, return the two month int. e.g. 1, 3, 5, 7, 9, 11. |
static int |
yearOfDate(java.util.Date when,
java.util.TimeZone tz)
Get the year of a date. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Dates()
Method Detail |
---|
public static final java.util.Date round(java.util.Date date, int precision)
now(int)
for details.
precision
- the divider of the precision(e.g. 10 for precision
of 10 milliseconds;i.e. all millisecond less than 10 would be truncated)now(int)
,
round(long, int)
public static final long round(long time, int precision)
time
- the date represented in long.precision
- the divider of the precision(e.g. 10 for precision
of 10 milliseconds;i.e. all millisecond less than 10 would be truncated)now(int)
,
round(Date, int)
public static final boolean isRounded(java.util.Date date, int precision)
public static final java.util.Date now(int precision)
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.
round(Date, int)
public static final java.util.Date now()
public static final java.util.Date today()
public static final java.util.Date previousDate(java.util.Date when)
public static final java.util.Date beginOfMonth()
public static final java.util.Date beginOfMonth(java.util.Date when, java.util.TimeZone tz)
public static final java.util.Date endOfMonth()
public static final java.util.Date endOfMonth(java.util.Date when, java.util.TimeZone tz)
public static final boolean isEndOfMonth(java.util.Date when, java.util.TimeZone tz)
public static final boolean isBeginOfMonth(java.util.Date when, java.util.TimeZone tz)
public static final java.util.Date beginOfDate(java.util.Date when, java.util.TimeZone tz)
public static final java.util.Date endOfDate(java.util.Date when, java.util.TimeZone tz)
public static final java.util.Date beginOfYear()
public static final java.util.Date beginOfYear(java.util.Date when, java.util.TimeZone tz)
public static final java.util.Date endOfYear()
public static final java.util.Date endOfYear(java.util.Date when, java.util.TimeZone tz)
public static final short twoMonthShort()
public static final short twoMonthShort(java.util.Date when, java.util.TimeZone tz)
public static final int yearOfDate(java.util.Date when, java.util.TimeZone tz)
when
- The date.tz
- The time zone; if null, the current time zone is assumed.localizedYearOfDate(java.util.Date, java.util.Locale, java.util.TimeZone)
public static final int localizedYearOfDate(java.util.Date when, java.util.Locale locale, java.util.TimeZone tz)
Currently, only Locale.ZH_TW is supported, i.e.,
"year - 1911" and it's may be less than 0. Otherwise, it is the same
as yearOfDate(java.util.Date, java.util.TimeZone)
.
when
- The date.locale
- the locale; if null, the current locale is assumed.tz
- The time zone; if null, the current time zone is assumed.yearOfDate(java.util.Date, java.util.TimeZone)
public static final int monthOfDate(java.util.Date when, java.util.TimeZone tz)
when
- The date.tz
- The time zone; if null, the current time zone is assumed.public static final int monthOfDatePlus1(java.util.Date when, java.util.TimeZone tz)
when
- The date.tz
- The time zone; if null, the current time zone is assumed.public static final int dayMonthOfDate(java.util.Date when, java.util.TimeZone tz)
when
- The date.tz
- The time zone; if null, the current time zone is assumed.public static final java.util.Date add(java.util.Date when, java.util.TimeZone tz, int field, int amount)
when
- The based date.tz
- The time zone; if null, the current time zone is assumed.field
- The time field.amount
- The amount of date or time to be added to the field.public static final long subtract(java.util.Date date2, java.util.TimeZone tz, int field, java.util.Date date1)
date2
- The date2.tz
- The time zone.field
- The time field; e.g., Calendar.DATE, Calendar.YEAR, it's default value is Calendar.DATEdate1
- The date1.public static final java.util.Date merge(java.util.Date datePart, java.util.Date timePart, java.util.TimeZone tz)
datePart
- The date part date.timePart
- The time part date.tz
- The time zone.public static final long getTimezoneOffset(java.util.TimeZone timezone, java.util.Date date)
timezone
- The time zone.date
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |