Class DateUtil

java.lang.Object
com.mirth.connect.server.userutil.DateUtil

public class DateUtil extends Object
Provides date/time utility methods.
  • Method Details

    • getDate

      public static Date getDate(String pattern, String date) throws Exception
      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

      public static String formatDate(String pattern, Date date)
      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

      public static String getCurrentDate(String pattern)
      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

      public static String convertDate(String inPattern, String outPattern, String date) throws Exception
      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.