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
.
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, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.