LocalDateTimeUtil
This class provides utility methods for working with LocalDateTime objects. It includes methods for formatting, parsing, and extracting various date and time components.
Methods
formatted(date: LocalDateTime): String
Returns a default formatted string using the workflow's default formatting.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object to format.
Returns:
A string representation of the formatted LocalDateTime.
format(date: LocalDateTime, format: String): String
Formats a LocalDateTime object using a custom date and time format pattern.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object to format.format
(type: String) - The custom date and time format pattern. Follows the pattern format from SimpleDateFormat for Java.
Returns:
A string representation of the formatted LocalDateTime based on the specified format pattern.
parse(dateStr: String, format: String): LocalDateTime
Parses a date string using a custom format and returns a LocalDateTime object.
Parameters:
dateStr
(type: String) - The date string to parse.format
(type: String) - The custom date and time format pattern used for parsing.
Returns:
A LocalDateTime object representing the parsed date and time.
getYear(date: LocalDateTime): Integer
Retrieves the year component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the year.
Returns:
An integer representing the year component.
getDayOfYear(date: LocalDateTime): Integer
Retrieves the day of the year component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the day of the year.
Returns:
An integer representing the day of the year.
getMonthName(date: LocalDateTime): String
Retrieves the name of the month for a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the month name.
Returns:
A string representing the name of the month.
getMonth(date: LocalDateTime): Integer
Retrieves the month component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the month.
Returns:
An integer representing the month.
getDayOfWeek(date: LocalDateTime): String
Retrieves the day of the week for a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the day of the week.
Returns:
A string representing the day of the week.
getDayOfMonth(date: LocalDateTime): Integer
Retrieves the day of the month component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the day of the month.
Returns:
An integer representing the day of the month.
getHour(date: LocalDateTime): Integer
Retrieves the hour component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the hour.
Returns:
An integer representing the hour.
getMinute(date: LocalDateTime): Integer
Retrieves the minute component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the minute.
Returns:
An integer representing the minute.
getSecond(date: LocalDateTime): Integer
Retrieves the second component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the second.
Returns:
An integer representing the second.
getNano(date: LocalDateTime): Integer
Retrieves the nanosecond component of a LocalDateTime.
Parameters:
date
(type: LocalDateTime) - The LocalDateTime object from which to extract the nanosecond.
Returns:
An integer representing the nanosecond.
These methods provide various operations to work with LocalDateTime objects, including formatting, parsing, and extracting individual date and time components.