Java LocalDate from String parseLocalDate(String dateString)

Here you can find the source of parseLocalDate(String dateString)

Description

parse Local Date

License

Open Source License

Declaration

public static Optional<LocalDate> parseLocalDate(String dateString) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

import java.time.format.DateTimeParseException;

import java.util.Optional;

public class Main {
    private static DateTimeFormatter DEFAULT_DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME;

    public static Optional<LocalDate> parseLocalDate(String dateString) {
        try {/*from  w w w .  ja  va  2  s. co  m*/
            return Optional.of(DEFAULT_DATE_FORMATTER.parse(dateString, LocalDate::from));
        } catch (DateTimeParseException e) {
            return Optional.empty();
        }
    }
}

Related

  1. getLocalDateForString(final String string)
  2. getLocalDateFromString(String sDate)
  3. parseLocalDate(String inPattern, String inDate)
  4. parseLocalDate(String localDate)
  5. parseStringToLocalDate(String strDate)
  6. toLocalDate(String date)