Package com.restfb.util
Class DateUtils
- java.lang.Object
-
- com.restfb.util.DateUtils
-
public final class DateUtils extends Object
A collection of date-handling utility methods.- Since:
- 1.6
- Author:
- Mark Allen
-
-
Field Summary
Fields Modifier and Type Field Description static String
FACEBOOK_ALTERNATE_SHORT_DATE_FORMAT
Facebook alternate short date format.static String
FACEBOOK_LONG_DATE_FORMAT
Facebook "long" date format (IETF RFC 3339).static String
FACEBOOK_LONG_DATE_FORMAT_WITHOUT_TIMEZONE
Facebook "long" date format (IETF RFC 3339) without a timezone component.static String
FACEBOOK_LONG_DATE_FORMAT_WITHOUT_TIMEZONE_OR_SECONDS
Facebook "long" date format (IETF RFC 3339) without a timezone or seconds component.static String
FACEBOOK_MONTH_YEAR_DATE_FORMAT
Facebook month-year only date format.static String
FACEBOOK_SHORT_DATE_FORMAT
Facebook short date format.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateFormatStrategy
getDateFormatStrategy()
get the current DateFormatStrategy.static void
setDateFormatStrategy(DateFormatStrategy dateFormatStrategy)
set theDateFormatStrategy
.static Date
toDateFromLongFormat(String date)
Returns a Java representation of a Facebook "long"date
string, or the number of seconds since the epoch.static Date
toDateFromMonthYearFormat(String date)
Returns a Java representation of a Facebook "month-year"date
string.static Date
toDateFromShortFormat(String date)
Returns a Java representation of a Facebook "short"date
string.static String
toLongFormatFromDate(Date date)
Returns a String representation of adate
objectstatic String
toShortFormatFromDate(Date date)
Returns a short String representation of adate
object
-
-
-
Field Detail
-
FACEBOOK_LONG_DATE_FORMAT
public static final String FACEBOOK_LONG_DATE_FORMAT
Facebook "long" date format (IETF RFC 3339). Example:2010-02-28T16:11:08+0000
- See Also:
- Constant Field Values
-
FACEBOOK_LONG_DATE_FORMAT_WITHOUT_TIMEZONE
public static final String FACEBOOK_LONG_DATE_FORMAT_WITHOUT_TIMEZONE
Facebook "long" date format (IETF RFC 3339) without a timezone component. Example:2010-02-28T16:11:08
- See Also:
- Constant Field Values
-
FACEBOOK_LONG_DATE_FORMAT_WITHOUT_TIMEZONE_OR_SECONDS
public static final String FACEBOOK_LONG_DATE_FORMAT_WITHOUT_TIMEZONE_OR_SECONDS
Facebook "long" date format (IETF RFC 3339) without a timezone or seconds component. Example:2010-02-28T16:11
- See Also:
- Constant Field Values
-
FACEBOOK_SHORT_DATE_FORMAT
public static final String FACEBOOK_SHORT_DATE_FORMAT
Facebook short date format. Example:04/15/1984
- See Also:
- Constant Field Values
-
FACEBOOK_ALTERNATE_SHORT_DATE_FORMAT
public static final String FACEBOOK_ALTERNATE_SHORT_DATE_FORMAT
Facebook alternate short date format. Example:2012-09-15
- See Also:
- Constant Field Values
-
FACEBOOK_MONTH_YEAR_DATE_FORMAT
public static final String FACEBOOK_MONTH_YEAR_DATE_FORMAT
Facebook month-year only date format. Example:Example: 2007-03
- See Also:
- Constant Field Values
-
-
Method Detail
-
toDateFromLongFormat
public static Date toDateFromLongFormat(String date)
Returns a Java representation of a Facebook "long"date
string, or the number of seconds since the epoch.Supports dates with or without timezone information.
- Parameters:
date
- Facebookdate
string.- Returns:
- Java date representation of the given Facebook "long"
date
string ornull
ifdate
isnull
or invalid.
-
toDateFromShortFormat
public static Date toDateFromShortFormat(String date)
Returns a Java representation of a Facebook "short"date
string.- Parameters:
date
- Facebookdate
string.- Returns:
- Java date representation of the given Facebook "short"
date
string ornull
ifdate
isnull
or invalid.
-
toDateFromMonthYearFormat
public static Date toDateFromMonthYearFormat(String date)
Returns a Java representation of a Facebook "month-year"date
string.- Parameters:
date
- Facebookdate
string.- Returns:
- Java date representation of the given Facebook "month-year"
date
string ornull
ifdate
isnull
or invalid.
-
toLongFormatFromDate
public static String toLongFormatFromDate(Date date)
Returns a String representation of adate
object- Parameters:
date
- as Date- Returns:
- String representation of a
date
object. The String is in the form2010-02-28T16:11:08
-
toShortFormatFromDate
public static String toShortFormatFromDate(Date date)
Returns a short String representation of adate
object- Parameters:
date
- as Date- Returns:
- String representation of a
date
object. The String is in the form2019-06-14
-
getDateFormatStrategy
public static DateFormatStrategy getDateFormatStrategy()
get the current DateFormatStrategy.- Returns:
- the current DateFormatStrategy
-
setDateFormatStrategy
public static void setDateFormatStrategy(DateFormatStrategy dateFormatStrategy)
set theDateFormatStrategy
.default value:
SimpleDateFormatStrategy
- Parameters:
dateFormatStrategy
- the usedDateFormatStrategy
-
-