public final class DateFormatter extends Object
The GNU Lesser General Public License for details.
The copyright to this program is held by its authors.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT
Constant for default style pattern.
|
private static String |
DEFAULT_DATE_FORMAT_CLASS |
private static String |
DEFAULT_SIMPLE_DATE_FORMAT_CLASS |
private static Class<?> |
defaultDateFormat |
private static Class<?> |
defaultSimpleDateFormat |
private Object |
formatter
The actual formatter.
|
private Class<?> |
formatterClass
The class of the formatter
|
static int |
FULL
Constant for full style pattern.
|
private static org.slf4j.Logger |
LOGGER |
static int |
LONG
Constant for long style pattern.
|
static int |
MEDIUM
Constant for medium style pattern.
|
static int |
SHORT
Constant for short style pattern.
|
Modifier | Constructor and Description |
---|---|
private |
DateFormatter()
Prevent instantiation.
|
Modifier and Type | Method and Description |
---|---|
String |
format(Date date)
Formats a Date into a date/time string.
|
static DateFormatter |
getDateInstance()
Construct a DateFormatter with the default date format.
|
static DateFormatter |
getDateInstance(int format)
Construct a DateFormatter with the given date format.
|
static DateFormatter |
getSimpleDateInstance(String format)
Construct a simple DateFormatter with the given date format.
|
Date |
parse(String text)
Convert text to a date.
|
void |
setLenient(boolean lenient)
Set whether this DataFormatter should be lenient in parsing dates.
|
public static final int FULL
public static final int LONG
public static final int MEDIUM
public static final int SHORT
public static final int DEFAULT
private static final org.slf4j.Logger LOGGER
private static final String DEFAULT_SIMPLE_DATE_FORMAT_CLASS
private static final String DEFAULT_DATE_FORMAT_CLASS
private Object formatter
private Class<?> formatterClass
private static Class<?> defaultSimpleDateFormat
private static Class<?> defaultDateFormat
public static DateFormatter getDateInstance(int format)
format
- the date formatDateFormat.getDateInstance(int)
public static DateFormatter getDateInstance()
DateFormat.getDateInstance()
public static DateFormatter getSimpleDateInstance(String format)
format
- the date formatDateFormat.getDateInstance(int)
public void setLenient(boolean lenient)
lenient
- whether to be lenient or notDateFormat.setLenient(boolean)
public String format(Date date)
date
- the time value to be formatted into a time string.DateFormat.format(java.util.Date)
public Date parse(String text)
text
- the input to parse as a dateDateFormat.parse(java.lang.String)