com.mirth.connect.server.userutil
Class DateUtil

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

public class DateUtil
extends java.lang.Object

Provides date/time utility methods.


Method Summary
static java.lang.String convertDate(java.lang.String inPattern, java.lang.String outPattern, java.lang.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 java.lang.String formatDate(java.lang.String pattern, java.util.Date date)
          Formats a java.util.Date object into a string according to a specified pattern.
static java.lang.String getCurrentDate(java.lang.String pattern)
          Formats the current date into a string according to a specified pattern.
static java.util.Date getDate(java.lang.String pattern, java.lang.String date)
          Parses a date string according to the specified pattern and returns a java.util.Date object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDate

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

formatDate

public static java.lang.String formatDate(java.lang.String pattern,
                                          java.util.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 java.lang.String getCurrentDate(java.lang.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 java.lang.String convertDate(java.lang.String inPattern,
                                           java.lang.String outPattern,
                                           java.lang.String date)
                                    throws java.lang.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:
java.lang.Exception