LocalTime.parse
Since you only have a time use the LocalTime
class. No need to define a formatting pattern in your case.
String str = "12:22:10";
LocalTime time = LocalTime.parse(str);
See that code run live at IdeOne.com.
See Oracle Tutorial for more info.
More Related Contents:
- Problem with parse a LocalDateTime using java 8
- How to parse/format dates with LocalDateTime? (Java 8)
- Convert java.util.Date to java.time.LocalDate
- `uuuu` versus `yyyy` in `DateTimeFormatter` formatting pattern codes in Java?
- Converting between java.time.LocalDateTime and java.util.Date
- Cannot parse String in ISO 8601 format, lacking colon in offset, to Java 8 Date
- UnsupportedTemporalTypeException when formatting Instant to String
- Difference between year-of-era and week-based-year?
- How to get milliseconds from LocalDateTime in Java 8
- How can I create a Java 8 LocalDate from a long Epoch time in Milliseconds?
- Differences between Java 8 Date Time API (java.time) and Joda-Time
- Mocking time in Java 8’s java.time API
- Can’t parse String to LocalDate (Java 8)
- How can I parse/format dates with LocalDateTime? (Java 8)
- Format a date using the new date time API
- Parse error: syntax error, unexpected T_STRING in app/design/frontend/base/default/template/catalog/product/new.phtml on line 37 [closed]
- What’s the difference between Instant and LocalDateTime?
- How to parse freeform street/postal address out of text, and into components
- Java 8: Difference between two LocalDateTime in multiple units
- How do I convert an ISO8601 TimeSpan to a C# TimeSpan?
- Handling extra operators in Shunting-yard
- Formatting a Duration in Java 8 / jsr310
- Difference between constituency parser and dependency parser
- Parse a string containing date and time in a custom format
- Looking for a clear definition of what a “tokenizer”, “parser” and “lexers” are and how they are related to each other and used?
- Java 8 LocalDate – How do I get all dates between two dates?
- Use Scala parser combinator to parse CSV files
- What is the motivation for two different week-based-year definitions in JSR-310?
- How to identify whether a grammar is LL(1), LR(0) or SLR(1)?
- Persist java.time.Instant (JDK8) with JPA2/Hibernate