public class LocalTimeStringConverter extends StringConverter<LocalTime>
StringConverter
implementation for LocalTime
values.
LocalDateStringConverter
,
LocalDateTimeStringConverter
Constructor and Description |
---|
LocalTimeStringConverter()
Create a
StringConverter for LocalTime values, using a
default formatter and parser with FormatStyle.SHORT , and the
user's Locale . |
LocalTimeStringConverter(DateTimeFormatter formatter,
DateTimeFormatter parser)
|
LocalTimeStringConverter(FormatStyle timeStyle)
Create a
StringConverter for LocalTime values, using a
default formatter and parser with the specified FormatStyle and
based on the user's Locale . |
LocalTimeStringConverter(FormatStyle timeStyle,
Locale locale)
Create a StringConverter for
LocalTime values, using a
default formatter and parser with the specified FormatStyle
and Locale . |
Modifier and Type | Method and Description |
---|---|
LocalTime |
fromString(String value)
Converts the string provided into an object defined by the specific converter.
|
String |
toString(LocalTime value)
Converts the object provided into its string form.
|
public LocalTimeStringConverter()
StringConverter
for LocalTime
values, using a
default formatter and parser with FormatStyle.SHORT
, and the
user's Locale
.public LocalTimeStringConverter(FormatStyle timeStyle)
StringConverter
for LocalTime
values, using a
default formatter and parser with the specified FormatStyle
and
based on the user's Locale
.timeStyle
- The FormatStyle
that will be used by the default
formatter and parser. If null then FormatStyle.SHORT
will be used.public LocalTimeStringConverter(FormatStyle timeStyle, Locale locale)
LocalTime
values, using a
default formatter and parser with the specified FormatStyle
and Locale
.timeStyle
- The FormatStyle
that will be used by the default
formatter and parser. If null then FormatStyle.SHORT
will be used.locale
- The Locale
that will be used by the default
formatter and parser. If null then
Locale.getDefault(Locale.Category.FORMAT)
will be used.public LocalTimeStringConverter(DateTimeFormatter formatter, DateTimeFormatter parser)
LocalTime
values using the
supplied formatter and parser, which are responsible for
choosing the desired Locale
.
For example, a fixed pattern can be used for converting both ways:
String pattern = "HH:mm:ss"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); StringConverterconverter = DateTimeStringConverter.getLocalTimeConverter(formatter, null);
formatter
- An instance of DateTimeFormatter
which
will be used for formatting by the toString() method. If null
then a default formatter will be used.parser
- An instance of DateTimeFormatter
which
will be used for parsing by the fromString() method. This can
be identical to formatter. If null, then formatter will be
used, and if that is also null, then a default parser will be
used.public LocalTime fromString(String value)
fromString
in class StringConverter<LocalTime>
public String toString(LocalTime value)
toString
in class StringConverter<LocalTime>
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.