Class DateUtils
java.lang.Object
id.luckynetwork.lyrams.lyralibs.core.utils.DateUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongdurationToLong(int duration, TimeUnit timeUnit) Convert a duration to milliseconds.longdurationToLong(String duration) It takes a string like "1h" or "2weeks" and converts it to a long value in millisecondsdurationToString(long duration) It converts a duration in milliseconds to a human-readable string.This function returns the current datevoidsetDateFormat(String format) This function sets the date format to the format specified by the user.voidsetTimeZone(String timeZone) Set the time zone for the date format.toDate(long millis) > It takes a long value representing milliseconds since the epoch, and returns a string representing the date in the format "yyyy-MM-dd"static longConverts the given amount of time in the given unit to ticks.
-
Constructor Details
-
DateUtils
public DateUtils()
-
-
Method Details
-
setDateFormat
This function sets the date format to the format specified by the user.- Parameters:
format- The format of the date.
-
setTimeZone
Set the time zone for the date format.- Parameters:
timeZone- The time zone to use for the date format.
-
getFormattedDate
This function returns the current date- Returns:
- The current date and time
-
toDate
> It takes a long value representing milliseconds since the epoch, and returns a string representing the date in the format "yyyy-MM-dd"- Parameters:
millis- The time in milliseconds to convert to a date.- Returns:
- A string representation of the date.
-
toTicks
Converts the given amount of time in the given unit to ticks.- Parameters:
amount- The amount of time to converttimeUnit- The unit of time to convert to ticks.- Returns:
- The amount of ticks in the given amount of time.
-
durationToLong
Convert a duration to milliseconds.- Parameters:
duration- The amount of time to converttimeUnit- The time unit of the duration parameter.- Returns:
- The duration in milliseconds.
-
durationToLong
It takes a string like "1h" or "2weeks" and converts it to a long value in milliseconds- Parameters:
duration- The duration string to convert.- Returns:
- The duration in milliseconds.
-
durationToString
It converts a duration in milliseconds to a human-readable string.- Parameters:
duration- The duration in milliseconds- Returns:
- A string that represents the duration in months, days, hours, minutes, and seconds.
-