Class DateUtil
java.lang.Object
com.mirth.connect.server.userutil.DateUtil
Provides date/time utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertDate(String inPattern, String outPattern, String date) Parses a date string according to a specified input pattern, and formats the date back to a string according to a specified output pattern.static StringformatDate(String pattern, Date date) Formats a java.util.Date object into a string according to a specified pattern.static StringgetCurrentDate(String pattern) Formats the current date into a string according to a specified pattern.static DateParses a date string according to the specified pattern and returns a java.util.Date object.
-
Method Details
-
getDate
Parses a date string according to the specified pattern and returns a java.util.Date object.- Parameters:
pattern- The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss").date- The date string to parse.- Returns:
- A java.util.Date object representing the parsed date.
- Throws:
Exception- If the pattern could not be parsed.
-
formatDate
Formats a java.util.Date object into a string according to a specified pattern.- Parameters:
pattern- The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss").date- The java.util.Date object to format.- Returns:
- The formatted date string.
-
getCurrentDate
Formats the current date into a string according to a specified pattern.- Parameters:
pattern- The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss").- Returns:
- The current formatted date string.
-
convertDate
Parses a date string according to a specified input pattern, and formats the date back to a string according to a specified output pattern.- Parameters:
inPattern- The SimpleDateFormat pattern to use for parsing the inbound date string (e.g. "yyyyMMddHHmmss").outPattern- The SimpleDateFormat pattern to use for formatting the outbound date string (e.g. "yyyyMMddHHmmss").date- The date string to convert.- Returns:
- The converted date string.
- Throws:
Exception- If the pattern could not be parsed.
-