public class DateTimeStringConverter extends StringConverter<java.util.Date>
StringConverter
implementation for Date
values that
represent a date and time.
DateStringConverter
,
TimeStringConverter
Modifier and Type | Field and Description |
---|---|
protected java.text.DateFormat |
dateFormat |
protected int |
dateStyle |
protected java.util.Locale |
locale |
protected java.lang.String |
pattern |
protected int |
timeStyle |
Constructor and Description |
---|
DateTimeStringConverter()
|
DateTimeStringConverter(java.text.DateFormat dateFormat)
|
DateTimeStringConverter(int dateStyle,
int timeStyle)
|
DateTimeStringConverter(java.util.Locale locale)
Create a
StringConverter for Date values, using the
specified locale and DateFormat.DEFAULT styles for date and time. |
DateTimeStringConverter(java.util.Locale locale,
int dateStyle,
int timeStyle)
Create a
StringConverter for Date values, using specified
locale and DateFormat styles for date and time. |
DateTimeStringConverter(java.util.Locale locale,
java.lang.String pattern)
Create a
StringConverter for Date values, using the
specified locale and pattern. |
DateTimeStringConverter(java.lang.String pattern)
Create a
StringConverter for Date values, using the
specified pattern. |
Modifier and Type | Method and Description |
---|---|
java.util.Date |
fromString(java.lang.String value)
Converts the string provided into an object defined by the specific converter.
|
protected java.text.DateFormat |
getDateFormat()
Return a
DateFormat instance to use for formatting
and parsing in this StringConverter . |
java.lang.String |
toString(java.util.Date value)
Converts the object provided into its string form.
|
protected final java.util.Locale locale
protected final java.lang.String pattern
protected final java.text.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(java.util.Locale locale)
StringConverter
for Date
values, using the
specified locale and DateFormat.DEFAULT
styles for date and time.locale
- the given locale.public DateTimeStringConverter(java.util.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(java.lang.String pattern)
StringConverter
for Date
values, using the
specified pattern.pattern
- the pattern describing the date and time format.public DateTimeStringConverter(java.util.Locale locale, java.lang.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(java.text.DateFormat dateFormat)
dateFormat
- the DateFormat
to be used for formatting and
parsing.public java.util.Date fromString(java.lang.String value)
fromString
in class StringConverter<java.util.Date>
public java.lang.String toString(java.util.Date value)
toString
in class StringConverter<java.util.Date>
protected java.text.DateFormat getDateFormat()
Return a DateFormat
instance to use for formatting
and parsing in this StringConverter
.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.