public class DateTimeStringConverter extends StringConverter<Date>
StringConverter implementation for Date values that
represent a date and time.
DateStringConverter,
TimeStringConverter| Modifier and Type | Field and Description |
|---|---|
protected DateFormat |
dateFormat |
protected int |
dateStyle |
protected Locale |
locale |
protected String |
pattern |
protected int |
timeStyle |
| Constructor and Description |
|---|
DateTimeStringConverter()
|
DateTimeStringConverter(DateFormat dateFormat)
|
DateTimeStringConverter(int dateStyle,
int timeStyle)
|
DateTimeStringConverter(Locale locale)
Create a
StringConverter for Date values, using the
specified locale and DateFormat.DEFAULT styles for date and time. |
DateTimeStringConverter(Locale locale,
int dateStyle,
int timeStyle)
Create a
StringConverter for Date values, using specified
locale and DateFormat styles for date and time. |
DateTimeStringConverter(Locale locale,
String pattern)
Create a
StringConverter for Date values, using the
specified locale and pattern. |
DateTimeStringConverter(String pattern)
Create a
StringConverter for Date values, using the
specified pattern. |
| Modifier and Type | Method and Description |
|---|---|
Date |
fromString(String value)
Converts the string provided into an object defined by the specific converter.
|
protected DateFormat |
getDateFormat()
Return a
DateFormat instance to use for formatting
and parsing in this StringConverter. |
String |
toString(Date value)
Converts the object provided into its string form.
|
protected final Locale locale
protected final String pattern
protected final DateFormat dateFormat
protected final int dateStyle
protected final int timeStyle
public DateTimeStringConverter()
public DateTimeStringConverter(int dateStyle,
int timeStyle)
dateStyle - the given formatting style. For example,
DateFormat.SHORT for "M/d/yy" in the US locale.timeStyle - the given formatting style. For example,
DateFormat.SHORT for "h:mm a" in the US locale.public DateTimeStringConverter(Locale locale)
StringConverter for Date values, using the
specified locale and DateFormat.DEFAULT styles for date and time.locale - the given locale.public DateTimeStringConverter(Locale locale, int dateStyle, int timeStyle)
StringConverter for Date values, using specified
locale and DateFormat styles for date and time.locale - the given locale.dateStyle - the given formatting style. For example,
DateFormat.SHORT for "M/d/yy" in the US locale.timeStyle - the given formatting style. For example,
DateFormat.SHORT for "h:mm a" in the US locale.public DateTimeStringConverter(String pattern)
StringConverter for Date values, using the
specified pattern.pattern - the pattern describing the date and time format.public DateTimeStringConverter(Locale locale, String pattern)
StringConverter for Date values, using the
specified locale and pattern.locale - the given locale.pattern - the pattern describing the date and time format.public DateTimeStringConverter(DateFormat dateFormat)
dateFormat - the DateFormat to be used for formatting and
parsing.public Date fromString(String value)
fromString in class StringConverter<Date>public String toString(Date value)
toString in class StringConverter<Date>protected DateFormat getDateFormat()
Return a DateFormat instance to use for formatting
and parsing in this StringConverter.
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.