LocalDateTime parse(CharSequence text, DateTimeFormatter formatter) example
Description
LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)
gets
an instance of LocalDateTime from a text string using a specific formatter.
Syntax
parse
has the following syntax.
public static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)
Example
The following example shows how to use parse
.
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/*from w ww. j av a2 s .co m*/
public class Main {
public static void main(String[] args) {
LocalDateTime a = LocalDateTime.parse("2014-06-30T12:01:00",DateTimeFormatter.ISO_DATE_TIME);
System.out.println(a);
}
}
The code above generates the following result.