Package org.exoplatform.commons.utils
Class TimeConvertUtils
java.lang.Object
org.exoplatform.commons.utils.TimeConvertUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertXTimeAgo(Date myDate, String format) static StringconvertXTimeAgo(Date myDate, String format, int limit) static StringconvertXTimeAgo(Date myDate, String format, Locale locale) static StringconvertXTimeAgo(Date myDate, String format, Locale locale, int limit) Convert date to display string with format X time agostatic StringconvertXTimeAgoByTimeServer(Date myDate, String format, Locale locale, int limit) Convert date to display string with format X time agostatic StringgetFormatDate(Date myDate, String format) static StringgetFormatDate(Date myDate, String format, Locale locale) static CalendarGet current time GMT/Zulu or UTC,(zone time is 0+GMT)static LocaleGet currentLocalestatic StringsantializeJavaVariable(String input) Cleanup the string to be valid of Java variable Ex: input = "123 sdkjh s;:sdlkjh d" output = "_123_sdkjh_s__sdlkjh_d"
-
Field Details
-
strs
-
DAY
public static int DAY -
WEEK
public static int WEEK -
MONTH
public static int MONTH -
YEAR
public static int YEAR
-
-
Constructor Details
-
TimeConvertUtils
public TimeConvertUtils()
-
-
Method Details
-
convertXTimeAgo
-
convertXTimeAgo
-
convertXTimeAgo
-
convertXTimeAgoByTimeServer
public static String convertXTimeAgoByTimeServer(Date myDate, String format, Locale locale, int limit) Convert date to display string with format X time ago- Parameters:
myDate- The object date input for convert, it must has ZoneTime is server ZoneTimeformat- The date/time formatlocale- The Local of current location(language/country).limit- The value set for limit convert x time ago. It must is: TimeConvertUtils.YEAR, MONTH, WEEK, DAY.- Returns:
- String
-
convertXTimeAgo
Convert date to display string with format X time ago- Parameters:
myDate- The object date input for convert, it must has ZoneTime is GMT+0format- The date/time formatlocale- The Local of current location(language/country).limit- The value set for limit convert x time ago. It must is: TimeConvertUtils.YEAR, MONTH, WEEK, DAY.- Returns:
- String
-
getFormatDate
-
getFormatDate
-
getLocale
Get currentLocale- Returns:
Locale
-
getGreenwichMeanTime
Get current time GMT/Zulu or UTC,(zone time is 0+GMT)- Returns:
- Calendar
-
santializeJavaVariable
Cleanup the string to be valid of Java variable Ex: input = "123 sdkjh s;:sdlkjh d" output = "_123_sdkjh_s__sdlkjh_d"- Returns:
-