LocalDateTime parse(CharSequence text) example

Description

LocalDateTime parse(CharSequence text) gets an instance of LocalDateTime from a text string such as 2014-12-03T10:15:30.


The string must represent a valid date-time and is parsed using <code>DateTimeFormatter.ISO_LOCAL_DATE_TIME</code>.

Syntax

parse has the following syntax.


public static LocalDateTime parse(CharSequence text)

Example

The following example shows how to use parse.


import java.time.LocalDateTime;
//from   w  w  w  . jav  a 2  s  .c  o m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.parse("2014-06-30T12:01:00");
    
    System.out.println(a);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset