Class DateTimeStringConverter
- Direct Known Subclasses:
DateStringConverter, TimeStringConverter
A StringConverter implementation for Date values that represent dates and times. Instances of this class are
immutable unless created with the DateTimeStringConverter(DateFormat) constructor (with a non-null argument).
Note that using Date is not recommended in JDK versions where LocalDateTime is available, in which
case LocalDateTimeStringConverter should be used.
- Since:
- JavaFX 2.1
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aDateTimeStringConverterthat uses a formatter/parser based onDateFormat.DEFAULTfor both date and time styles, and the user'sLocale.DateTimeStringConverter(int dateStyle, int timeStyle) Creates aDateTimeStringConverterthat uses a formatter/parser based on the given date and time styles, and the user'sLocale.DateTimeStringConverter(String pattern) Creates aDateTimeStringConverterthat uses a formatter/parser based on the given pattern, and the user'sLocale.DateTimeStringConverter(DateFormat dateFormat) Creates aDateTimeStringConverterthat uses the given formatter/parser.DateTimeStringConverter(Locale locale) Creates aDateTimeStringConverterthat uses a formatter/parser based onDateFormat.DEFAULTfor both date and time styles, and the givenLocale.DateTimeStringConverter(Locale locale, int dateStyle, int timeStyle) Creates aDateTimeStringConverterthat uses a formatter/parser based on the given date and time styles, andLocale.DateTimeStringConverter(Locale locale, String pattern) Creates aDateTimeStringConverterthat uses a formatter/parser based on the given pattern andLocale. -
Method Summary
-
Constructor Details
-
DateTimeStringConverter
public DateTimeStringConverter()Creates aDateTimeStringConverterthat uses a formatter/parser based onDateFormat.DEFAULTfor both date and time styles, and the user'sLocale. -
DateTimeStringConverter
public DateTimeStringConverter(int dateStyle, int timeStyle) Creates aDateTimeStringConverterthat uses a formatter/parser based on the given date and time styles, and the user'sLocale.- Parameters:
dateStyle- the formatting style for dates. For example,DateFormat.SHORTfor "M/d/yy" in the US locale.timeStyle- the formatting style for times. For example,DateFormat.SHORTfor "h:mm a" in the US locale.- Since:
- JavaFX 8u40
-
DateTimeStringConverter
Creates aDateTimeStringConverterthat uses a formatter/parser based onDateFormat.DEFAULTfor both date and time styles, and the givenLocale.- Parameters:
locale- theLocalethat will be used by the formatter/parser. Ifnull, the user's locale will be used.
-
DateTimeStringConverter
Creates aDateTimeStringConverterthat uses a formatter/parser based on the given date and time styles, andLocale.- Parameters:
locale- theLocalethat will be used by the formatter/parser. Ifnull, the user's locale will be used.dateStyle- the formatting style for dates. For example,DateFormat.SHORTfor "M/d/yy" in the US locale.timeStyle- the formatting style for times. For example,DateFormat.SHORTfor "h:mm a" in the US locale.- Since:
- JavaFX 8u40
-
DateTimeStringConverter
Creates aDateTimeStringConverterthat uses a formatter/parser based on the given pattern, and the user'sLocale.- Parameters:
pattern- the pattern describing the date and time format. Ifnull,DateFormat.DEFAULTwill be used for both date and time.
-
DateTimeStringConverter
Creates aDateTimeStringConverterthat uses a formatter/parser based on the given pattern andLocale.- Parameters:
locale- theLocalethat will be used by the formatter/parser. Ifnull, the user's locale will be used.pattern- the pattern describing the date and time format. Ifnull,DateFormat.DEFAULTwill be used for both date and time styles.
-
DateTimeStringConverter
Creates aDateTimeStringConverterthat uses the given formatter/parser.- Parameters:
dateFormat- the formatter/parser that will be used by thetoString()andfromString()methods. Ifnull, a default formatter/parser will be used.
-
-
Method Details
-
fromString
-
toString
Converts an object to a string form. The format of the returned string is defined by the specific converter.nullis converted to an empty string, otherwise the type'stoStringis used.- Parameters:
value- the object of typeTto convert- Returns:
- a string representation of the object passed in
-