LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)
gets
an instance of LocalDateTime from a text string using a specific formatter.
parse
has the following syntax.
public static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)
The following example shows how to use parse
.
import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; //from w ww. ja va 2s .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.