|
Spiffy UI Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.spiffyui.client.JSDateUtil
public final class JSDateUtil
A collection of utility methods for manipulating dates in the browser.
JSDateUtil provide flexible locale aware support for formatting dates and times in GWT. This class fills in many of the gaps missing from the java.text package from the JDK.
In addition to standard date formatting this library supports custom formatting following the Spiffy UI date formatters specification.
Method Summary | |
---|---|
static java.util.Date |
dateAdd(java.util.Date date,
int amt,
java.lang.String unit)
Add to a specified date |
static java.lang.String |
dateAdd(java.lang.String epochDate,
int amt,
java.lang.String unit)
Add to a specified epoch date |
static java.lang.String |
format(java.util.Date date,
java.lang.String format)
Format the specified date according to the format string. |
static java.lang.String |
format(java.lang.String epochDate,
java.lang.String format)
Format the specified date according to the format string. |
static java.lang.String |
getDate(java.util.Date date)
Convert java.util.Date to Date format in the current locale |
static java.lang.String |
getDate(java.util.Date date,
java.lang.String format)
Convert UTC epoch format to a date string matching the specified format. |
static java.lang.String |
getDate(java.lang.String epochDate)
Convert UTC epoch format to short Date format in the current locale |
static java.lang.String |
getDate(java.lang.String epochDate,
java.lang.String format)
Convert UTC epoch format to a date string matching the specified format. |
static java.lang.String |
getEpoch(java.lang.String dateString)
Convert Date to UTC Epoch format |
static java.lang.String |
getFullDateTime(java.util.Date date)
Convert java.util.Date to Full Date Time format in the current locale |
static java.lang.String |
getFullDateTime(java.lang.String epochDate)
Convert UTC epoch format to Date Time format in the current locale |
static java.lang.String |
getFullDateTimeFormat()
Gets the full date time format string in the current locale. |
static int |
getHours(java.lang.String time)
Gets the hours from the specified short time string |
static java.lang.String |
getLocale()
Gets the current locale of the application running in the browser. |
static java.lang.String |
getLongDate(java.lang.String epochDate)
Convert UTC epoch format to Date format in the current locale |
static java.lang.String |
getLongDateFormat()
Gets the long date format string in the current locale. |
static int |
getMinutes(java.lang.String time)
Gets the minutes from the specified short time string |
static java.lang.String |
getMonthDay(java.lang.String epochDate,
boolean abbrev)
Convert UTC epoch format to Month Day format in the current locale |
static java.lang.String |
getMonthDayFormat()
Gets the month day format string in the current locale. |
static int |
getOrdinalNumber(java.util.Date date)
Get the Ordinal day (numeric day number) of the year, adjusted for leap year. |
static int |
getOrdinalNumber(java.lang.String epochDate)
Get the Ordinal day (numeric day number) of the year, adjusted for leap year. |
static java.lang.String |
getShortDate(java.lang.String epochDate)
Convert UTC epoch format to short Date format in the current locale |
static java.lang.String |
getShortDateFormat()
Gets the short date format string in the current locale. |
static java.lang.String |
getShortDateTime(java.util.Date date)
Converts a java.util.Date to a concatenation of the Short Date and Short Time format in the current locale |
static java.lang.String |
getShortMonthDayTime(java.lang.String epochDate)
Convert UTC epoch format to Month Day format in the current locale concatenated with the Short Time |
static java.lang.String |
getShortTime(java.util.Date date)
Convert java.util.Date to Short Time format in the current locale |
static java.lang.String |
getShortTime(java.lang.String epochDate)
Convert UTC epoch format to short time format in the current locale |
static java.lang.String |
getShortTimeFormat()
Gets the short time format string in the current locale. |
static java.lang.String |
getShortTimeRounded(java.lang.String epochDate)
Convert UTC epoch format to short time format in the current locale rounded up to the nearest 30 minutes. |
static java.lang.String |
getToday()
Convert UTC epoch format to Date format in the current locale |
static int |
getUTCOffset()
Get the UTC offset of the current browser. |
static boolean |
is24Time()
Determines if the browser's current locale uses 24 hour time |
static java.lang.String |
nextDay()
Adds the 1 day to today |
static java.util.Date |
parseShortDate(java.lang.String dateString)
Convert the specified String to a date object using the short format of the current locale |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String getDate(java.util.Date date)
date
- - the Date object to convert
public static java.lang.String getShortDate(java.lang.String epochDate)
Convert UTC epoch format to short Date format in the current locale
epochDate
- - the time in milliseconds since Jan 1, 1970
public static java.lang.String getDate(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static java.lang.String getDate(java.util.Date date, java.lang.String format)
date
- - the date object to formatformat
- - the formatter for the date
public static java.lang.String format(java.util.Date date, java.lang.String format)
date
- - the date object to formatformat
- - the formatter for the date
public static java.lang.String format(java.lang.String epochDate, java.lang.String format)
epochDate
- - the long date to formatformat
- - the formatter for the date
public static java.lang.String getDate(java.lang.String epochDate, java.lang.String format)
epochDate
- - the time in milliseconds since Jan , 1, 1970format
- - the formatter for the date
public static java.lang.String getLongDate(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static java.lang.String getToday()
public static java.lang.String nextDay()
public static java.lang.String getShortTime(java.util.Date date)
date
- - the Date object to convert
public static java.lang.String getShortTime(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static java.lang.String getShortTimeRounded(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static int getHours(java.lang.String time)
time
- - the time 11:30pm
public static int getMinutes(java.lang.String time)
time
- - the time 11:30pm
public static java.lang.String getEpoch(java.lang.String dateString)
dateString
- - the String to test
public static java.lang.String getShortDateFormat()
public static java.lang.String getLongDateFormat()
public static java.lang.String getMonthDayFormat()
public static java.lang.String getShortTimeFormat()
public static java.lang.String getLocale()
Gets the current locale of the application running in the browser.
This methods returns the locale being used by GWT if the GWTLocaleFilter is used in the application. This locale is the best match between the user's preferred locale and the locales supported in the application. The user's preferred locale may be different than the installed locale of the browser.
For example, if the application is localized into English (en), French (fr), and Japanese (ja) the the user will get the follow locales:
The user's list of preferred locales is:
In this example the locale would be Japanese.
The user's list of preferred locales is:
In this example the user will get French because that is the closest exact match. If the application was localized into English - United Kingdom (en_GB) then the user would get that locale.
The user's list of preferred locales is:
In this example the user will get English because none of their preferred locales are supported and English is the default.
For more information on these processes see section 14.4 of the HTTP specification.
public static java.util.Date parseShortDate(java.lang.String dateString)
dateString
- - the String to convert
public static boolean is24Time()
public static java.lang.String getFullDateTimeFormat()
public static java.lang.String getFullDateTime(java.util.Date date)
date
- - the Date object to convert
public static java.lang.String getFullDateTime(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static java.lang.String getShortDateTime(java.util.Date date)
date
- - the Date object to convert
public static java.util.Date dateAdd(java.util.Date date, int amt, java.lang.String unit)
date
- - a Date to startamt
- - the amount to addunit
- - the unit to add. Can be WEEK, MONTH, YEAR, HOUR, MINUTE, SECOND or defaults to DAY
public static java.lang.String dateAdd(java.lang.String epochDate, int amt, java.lang.String unit)
epochDate
- - the time in milliseconds since Jan 1, 1970amt
- - the amount to addunit
- - the unit to add. Can be WEEK, MONTH, YEAR, HOUR, MINUTE, SECOND or defaults to DAY
public static java.lang.String getMonthDay(java.lang.String epochDate, boolean abbrev)
epochDate
- - the time in milliseconds since Jan 1, 1970abbrev
- - if true, then abbreviate the month
public static java.lang.String getShortMonthDayTime(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static int getOrdinalNumber(java.util.Date date)
date
- - a Date
public static int getOrdinalNumber(java.lang.String epochDate)
epochDate
- - the time in milliseconds since Jan 1, 1970
public static int getUTCOffset()
|
Spiffy UI Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |