public final class DateFormatUtil
extends java.lang.Object
DateFormat.getDateTimeInstance()
When formatting a Date object into a String then yyyy-MM-dd'T'HH:mm:ssZ will always be used.
DateFormat
Modifier and Type | Class and Description |
---|---|
static class |
DateFormatUtil.CustomDateFormat
Custom date formats over and above
SimpleDateFormat . |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
format(java.util.Date d)
Return the default formatted String for a given date.
|
static java.util.Date |
parse(java.lang.String s)
Return a date object from a given string.
|
static java.util.Date |
toDate(java.lang.String stringRep,
java.lang.String format)
Convert a string into a date.
|
static java.lang.String |
toString(java.util.Date d,
java.lang.String format)
Convert a date to a String.
|
public static java.util.Date parse(java.lang.String s)
s
- the date in string formatpublic static java.lang.String format(java.util.Date d)
d
- the datepublic static java.lang.String toString(java.util.Date d, java.lang.String format)
d
- the date to format.format
- the format which might be one of DateFormatUtil.CustomDateFormat
public static java.util.Date toDate(java.lang.String stringRep, java.lang.String format) throws java.text.ParseException
stringRep
- the string to convert.format
- the format of the date, which might be one of DateFormatUtil.CustomDateFormat
Date
java.text.ParseException
- if the format was invalid.