public class DateUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
convertDate(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 String |
formatDate(String pattern,
Date date)
Formats a java.util.Date object into a string according to a specified pattern.
|
static String |
getCurrentDate(String pattern)
Formats the current date into a string according to a specified pattern.
|
static Date |
getDate(String pattern,
String date)
Parses a date string according to the specified pattern and returns a java.util.Date object.
|
public static Date getDate(String pattern, String date) throws Exception
pattern - The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss").date - The date string to parse.Exception - If the pattern could not be parsed.public static String formatDate(String pattern, Date date)
pattern - The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss").date - The java.util.Date object to format.public static String getCurrentDate(String pattern)
pattern - The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss").public static String convertDate(String inPattern, String outPattern, String date) throws Exception
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.Exception - If the pattern could not be parsed.